[swift-corelibs-dev] NSString enumerateSubstrings

2017-07-24 Thread Andy Best via swift-corelibs-dev
Hey,

I've been working on implementing NSString enumerateSubstrings, and I was
wondering if anyone had any ideas about test cases.

My current implementation so far is here
https://github.com/andybest/swift-corelibs-foundation/commit/58ab2927a4678e54c5176be7113170d2bdf53d78

I've been testing locally against output from the Darwin implementation to
make sure they match, but I've only really got English test cases. Ideally
I'd want a bunch of test cases from various languages so I can make sure
that the corelibs version matches the Darwin version as closely as
possible, and hopefully pick up any edge cases. If anyone has any links to
pieces of text that could be good to test against, that would be great.
I've been mostly using excerpts from Project Gutenberg books so far.

Also, I'm guessing that I might not be able to use
NSMutableCharacterSet/CharacterSet casting under Linux, since the bridging
between those types is not implemented properly yet?


Thanks,

Andy
___
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev


Re: [swift-corelibs-dev] CFStringTokenizer

2017-06-22 Thread Andy Best via swift-corelibs-dev
Great, I'll do it that way then, thanks :)

On 22 June 2017 at 17:45, Philippe Hausler <phaus...@apple.com> wrote:

> That particular implementation is not part of the open source side of CF,
> so a re-implementation in Swift/C would be the way to go here.
>
> > On Jun 22, 2017, at 9:44 AM, Andy Best via swift-corelibs-dev <
> swift-corelibs-dev@swift.org> wrote:
> >
> > Hey,
> >
> > I'm looking at implementing the final missing NSString method (
> enumerateSubstrings(in:using:) ), and I noticed that there is no
> implementation of CFStringTokenizer in the provided CoreFoundation.
> >
> > Is this meant to be the case?
> >
> > If so, I'll go ahead and implement it in pure Swift
> >
> >
> > Andy
> > ___
> > swift-corelibs-dev mailing list
> > swift-corelibs-dev@swift.org
> > https://lists.swift.org/mailman/listinfo/swift-corelibs-dev
>
>
___
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev


[swift-corelibs-dev] CFStringTokenizer

2017-06-22 Thread Andy Best via swift-corelibs-dev
Hey,

I'm looking at implementing the final missing NSString method (
enumerateSubstrings(in:using:) ), and I noticed that there is no
implementation of CFStringTokenizer in the provided CoreFoundation.

Is this meant to be the case?

If so, I'll go ahead and implement it in pure Swift


Andy
___
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev


Re: [swift-corelibs-dev] Foundation: NSString init detect encoding

2017-06-21 Thread Andy Best via swift-corelibs-dev
Is the preferred approach to mirror Foundation as closely as possible (e.g.
under Linux basically do nothing), or is implementing something like
stringEncodingForData under the hood preferable in this case?

On 21 June 2017 at 17:43, Tony Parker <anthony.par...@apple.com> wrote:

> Hi Andy,
>
>
> On Jun 21, 2017, at 7:39 AM, Andy Best via swift-corelibs-dev <
> swift-corelibs-dev@swift.org> wrote:
>
> Hey,
>
> I've been looking at the init(contentsOfFile, usedEncoding) initializer
> for NSString in corelibs-foundation.
>
> Am I right in thinking that this method should use some method to attempt
> to detect the character encoding of the file before returning a decoded
> String?
>
>
> In this case, the Foundation implementation just looks at an extended
> attribute of the file to see if it contains the encoding. If it doesn’t
> have the xattr then we don’t attempt to guess (name of xattr is
> “com.apple.TextEncoding”).
>
> Foundation has another API which attempts to guess the encoding of a data
> blob, but I think we left it out of the swift-corelibs stubs:
>
> + (NSStringEncoding)stringEncodingForData:(NSData *)data
>   encodingOptions:(nullable NSDictionary<
> NSStringEncodingDetectionOptionsKey, id> *)opts
>   convertedString:(NSString * _Nullable *
> _Nullable)string
>   usedLossyConversion:(nullable BOOL
> *)usedLossyConversion API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0),
> tvos(9.0));
>
> - Tony
>
>
> If so, I've been working on a pure Swift library to detect string
> encodings, and wondered if continued work on it might be useful for
> implementing this missing method?
>
> Andy
> ___
> swift-corelibs-dev mailing list
> swift-corelibs-dev@swift.org
> https://lists.swift.org/mailman/listinfo/swift-corelibs-dev
>
>
>
___
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev


[swift-corelibs-dev] Foundation: NSString init detect encoding

2017-06-21 Thread Andy Best via swift-corelibs-dev
Hey,

I've been looking at the init(contentsOfFile, usedEncoding) initializer for
NSString in corelibs-foundation.

Am I right in thinking that this initializer should use some method to
attempt to detect the character encoding of the file before returning a
decoded String?

If so, I've been working on a pure Swift library to detect string
encodings, and wondered if continued work on it might be useful for
implementing this missing initializer?

Andy
___
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev