Skip navigation.
 
mlRe: Converting *u unicode hex sequences
FROM : Deborah Goldsmith
DATE : Tue Nov 06 03:38:11 2007

If you are running on 10.4 or later, you can use CFStringTransform.

CFStringTransform(myMutableString, range, CFSTR("Hex-Any"), NO);

"Hex-Any" is equivalent to "Hex-Any/Java", and the \u style is the one 
used in Java.

Deborah Goldsmith
Internationalization, Unicode Liaison
Apple Inc.
<email_removed>

On Nov 4, 2007, at 7:12 PM, <email_removed> wrote:

> Hello list.
>
> My code receives NSStrings containing unicode hex escapes that start 
> with asterisk (*) instead of backslash (\), and I need to decode 
> these strings.  For example, I need to convert @"hello*u0020world" 
> to @"hello world".
>
> Using NSMutableString replaceOccurrencesOfString:withString:range: 
> to convert @"*" to @"\\", yields @"hello\u0020world" as expected, 
> but I can't seem to get from there to @"hello world".
>
> I realize that \u0020 is neither percent-escaped nor UTF-8 encoded. 
> I've tried searching this list's archives, and the web in general, 
> all tried the variants of 
> stringByReplacingPercentEscapesUsingEncoding: and 
> stringWithCString:encoding: I can think of. I scanned the CFString 
> docs, but none of the functions jumped out at me.
>
> So, how does one convert from @"hello*u0020world" to @"hello world", 
> short of parsing the hex sequences?
>
> Thanks.
>
> _______________________________________________
>
> Cocoa-dev mailing list (<email_removed>)
>
> 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/<email_removed>
>
> This email sent to <email_removed>

Related mailsAuthorDate
mlConverting *u unicode hex sequences ncdev05 Nov 5, 04:12
mlRe: Converting *u unicode hex sequences John Stiles Nov 5, 16:22
mlRe: Converting *u unicode hex sequences Deborah Goldsmith Nov 6, 03:38