Unicode Character from Code in String (Obj-C)
I have a unicode hex value in an NSString – how do I output the character; here’s what I have:
NSLog(@"\U0001D000"); NSMutableString *hexString = [[NSMutableString alloc] initWithString:@"0001D000"]; [hexString insertString:@"\\U" atIndex:0]; NSLog(@"%@", hexString);
The first NSLog outputs the character; the second just produces the output “\U0001D000”
I’ve tried lots of combinations and am at a loss – for example, I tried
But this gives a complier error, as it is looking for a string of numbers after the \U
- Understanding UnicodeScalar initializers in Swift
- iOS NSLog error with Unicode characters
- How to convert string to unicode(UTF-8) string in Swift?
- Dynamically create NSString with Unicode emoji
- How to express Strings in Swift using Unicode hexadecimal values (UTF-16)
- numerical value of a unicode character in objective c
Solutions Collect From Internet About “Unicode Character from Code in String (Obj-C)”
If your character requires a surrogate pair (U+10000 to U+10FFFF), use
CFStringGetSurrogatePairForLongCharacter to convert the Unicode code point into a UTF-16 surrogate pair, and then
-initWithCharacters:length: to convert it into an NSString. For example:
UniChar c; CFStringGetSurrogatePairForLongCharacter(0x1D000, c); NSString *s = [[NSString alloc] initWithCharacters:c length:2];
For other characters (
FALSE), you can skip the conversion and go straight to
- Build static Graphviz libraries for iOS
- Low fps swift playgrounds?
- My app crashes when running on my iPhone, but not in the simulator. What are some debugging techniques I can use to reso the issue?
- iOS App Submission, Invalid Image Sizes
- Calling a Swift function from C++
- Can't cast video via google cast correctly in ios app
- Xcode Instruments error: “Allocations tracking library was not loaded in time”
- Is it possible to zoom UICollectionView as a unit?
- UIView rounded Corner – Swift 2.0?
- Make a dictionary value non-optional as extension
- Image on cells not all the way to the left
- removeFromSuperview doesn't work
- When is it better to use an NSSet over an NSArray?
- Swift NSCoding Not working
- CGRectContainsRect Not Working