Re: Convert unicode string into ascii
Re: Convert unicode string into ascii
- Subject: Re: Convert unicode string into ascii
- From: Wade Tregaskis <email@hidden>
- Date: Thu, 28 Aug 2008 11:53:07 -0700
is a way to convert an unicode string into a simple a-z>0-9 string
and replace the other wierd chars into a "." (full stop)?
im doing a small hex reader, so maybe this could help you.
CFDataRef CFStringCreateExternalRepresentation (
CFAllocatorRef alloc,
CFStringRef theString,
CFStringEncoding encoding,
UInt8 lossByte
);
-- OR --
CFIndex CFStringGetBytes (
CFStringRef theString,
CFRange range,
CFStringEncoding encoding,
UInt8 lossByte,
Boolean isExternalRepresentation,
UInt8 *buffer,
CFIndex maxBufLen,
CFIndex *usedBufLen
);
Pass kCFStringEncodingASCII as the desired encoding, '.' as your loss
byte. That won't limit you to purely alphanumerics - it allows
spaces, punctuation, etc. But it may be exactly what you want - it's
not clear from your original post.
Depending on how you then need to use the result, you may prefer one
or the other. In either case it's easy enough to convert back to a
CFString if that's what you ultimately need.
Wade
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden