Re: (newbie question) Putting special characters in NSStrings
Re: (newbie question) Putting special characters in NSStrings
- Subject: Re: (newbie question) Putting special characters in NSStrings
- From: Nicko van Someren <email@hidden>
- Date: Fri, 18 Mar 2005 21:39:57 +0000
On 18 Mar 2005, at 20:40, Matt Neuburg wrote:
On Fri, 18 Mar 2005 11:33:36 -0800, Ben Borofka <email@hidden>
said:
I have a bunch of special characters I need to put in NSStrings and
NSArrays of NSStrings:
" ! @ # $ % ^ *
I've been just using, for example, [[NSString alloc ]
initWithString:@"!"] to create the string but I don't think they are
working for all those special characters. What's the best way to put
those into an NSString? I can't find any simple, easy examples.
...
NSArray* a = [NSArray arrayWithObjects:
@"\"", @"!", @"#", @"$", @"%", @"^", @"*", nil];
...
It works fine. m.
On the other hand [NSArray arrayWithObjects: @"£", @"±", @"§", @"€",
nil] has some decidedly odd behaviour because X-code UTF-8 encodes the
top-bit set characters (in fact the Euro symbol is not even an 8 bit
character). In order to handle these you can use [NSString
stringWithUTF8String: "±§£€"], which will work as expected as long as
you select Format->File Encoding->Unicode (UTF-8), which is certainly
the default in the UK and may well be elsewhere.
Cheers,
Nicko
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden