( Oops, hit wrong button )

While working on making some adjustments to code that has been developed for 
OSX/iOS that would allow it to be portable to Linux, we are seeing a behavior 
that is causing some confusion. I’m not sure it is a bug, it may well be 
working as designed.

At issue the following code: (where value is an UnsafeMutablePointer<void> 
containing a pointer to a MacOSRomanStringEncoding of the string ‘hello’)

let data : NSData = NSData.init(bytes:value, length:len)
                let s : String = String.init(data:data,
                        encoding:NSMacOSRomanStringEncoding)!
                print("Value: \(s)")

On OSX, this results in a print of:


Value: hello


While on Linux it results in a print of:

Value: (Foundation.NSData, 30)

Is this an intentional design change, or is our simple test case written wrong, 
or something equally stupid? 







On 12/17/15, 10:27 AM, "[email protected] on behalf of Dru Satori 
via swift-users" <[email protected] on behalf of 
[email protected]> wrote:

>While working on making some adjustments to code that has been developed for 
>OSX/iOS that would allow it to be portable to Linux, we are seeing a behavior 
>that is causing some confusion. I’m not sure it is a bug, it may well be 
>working as designed.
>
>At issue the following code: (where value is an UnsafeMutablePointer<void> 
>containing a pointer to a MacOSRomanStringEncoding of the string ‘hello’)
>
>let data : NSData = NSData.init(bytes:value, length:len)
>               let s : String = String.init(data:data,
>                       encoding:NSMacOSRomanStringEncoding)!
>               print("Value: \(s)")
>
>
>
>On OSX, this results in a print of:


>
>
>
>
>_______________________________________________
>swift-users mailing list
>[email protected]
>https://lists.swift.org/mailman/listinfo/swift-users
_______________________________________________
swift-users mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to