Re: Unicode replaceOccuranceOfString?
Re: Unicode replaceOccuranceOfString?
- Subject: Re: Unicode replaceOccuranceOfString?
- From: Rachel Blackman <email@hidden>
- Date: Sun, 19 Sep 2004 01:56:51 -0700
Further, it seems there must be a better way to do replacements of a
few specific characters which simply don't happen to be
7-bit-safe...! Any advice would be very welcome...
Have you made sure your localized strings file uses UTF-16 Unicode
encoding?
Yep. But I ended up finding a way around my problem. Not the
prettiest method, but it works in a pinch, and I didn't have to use
localized strings. I just had to find the Unicode character numbers
for each, and create an NSString addition to make an NSString
containing a unicode character from a numeric value. Then it's just,
say, [NSString stringWithCharacterForUnicodeValue:0x2026] and voila,
you have a horizontal ellipse.
For those who care, it's:
+ (NSString *) stringWithCharacterForUnicodeValue:(UniChar)character
{
// Make a CFString with our Unicode character...
CFMutableStringRef myRef =
CFStringCreateWithCharacters(NULL,&character,1);
// Create an NSString copy of it so we don't need to muck about
with CFRelease elsewhere in code.
NSString *charString = [NSString stringWithString:(NSString
*)myRef];
// ...and free the CFString version.
CFRelease(myRef);
// I have a Unicode character!
return charString;
}
...silly, yes. Ugly, yes. But, functional!
--
Rachel 'Sparks' Blackman -- sysadmin, developer, mad scientist
"If it is not broken, give me five minutes to redesign it!"
_______________________________________________
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