Skip to content

Instantly share code, notes, and snippets.

@ksm
Created July 1, 2013 11:10
Show Gist options
  • Save ksm/5900007 to your computer and use it in GitHub Desktop.
Save ksm/5900007 to your computer and use it in GitHub Desktop.
Transliterate and normalize alphabets to latin
// Source: WWDC 2013 Session 228
CFMutableStringRef string = (__bridgeCFMutableStringRef)[@"Hello!こんにちは!สวสัดี!مرحبا!您好!" mutableCopy];
CFStringTransform(string, NULL, kCFStringTransformToLatin, NO);
// Hello! kon'nichiha! swạsdī! mrḥbạ! nín hǎo!
CFStringTransform(string, NULL, kCFStringTransformStripCombiningMarks, NO);
// Hello! kon'nichiha! swasdi! mrhba! nin hao!
CFStringLowercase(string, NULL);
// hello! kon'nichiha! swasdi! mrhba! nin hao!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment