On Aug 17, 2009, at 9:46 AM, Gernot A.Pohl wrote:

        NSString *halo = @"Hello, Wörld!";
        NSArray *array = [NSArray arrayWithObject:halo];
NSDictionary *dictionary = [NSDictionary dictionaryWithObject:halo forKey:@"halo"];
       NSLog(@"%...@\narray=%@\ndictionary=%@", halo, array, dictionary);
        /* I got on Leopard 10.5.8/Xcode 3.1.2:
2009-08-16 16:45:39.886 WhyDoWeHaveWeirdEncodingInCmdLineOut [2436:813] Hello, Wörld!
        array=(
                "Hello, W\U00f6rld!"
        )
        dictionary={
                halo = "Hello, W\U00f6rld!";
        }

Problem: HOW can I get the SAME NSString description output within the array/the dictionary description output???

In general, you should never rely on -description for output, since it's intended for debugging and may change between OS releases. In this case, NSDictionary and NSArray appear to be printing an old-style ASCII property list (NSPropertyListOpenStepFormat), which must use escapes for non-ASCII characters.

I need a real unicode character instead of '\U....' for a 'real' stdout in any NSString encoding but not in the given one (see my example).

You'll need to iterate the collections and print the contents yourself, or convert to XML using NSPropertyListSerialization and print that. If you need a specific encoding, use [[NSFileHandle fileHandleWithStandardOutput] writeData:[aString dataUsingEncoding:]].


Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to