I have a UITextField to enter a unicode value , when i tap a UIButton need to convert it and showing in a UILabel.
Th
0D05 is just a hexadecimal number. You can use NSScanner to parse the hexadecimal string into an integer, and then create a NSString containing the Unicode character.
NSString *hexString = yourInputField.text;
NSScanner *scanner = [NSScanner scannerWithString:hexString];
uint32_t unicodeInt;
if ([scanner scanHexInt:&unicodeInt]) {
unicodeInt = OSSwapHostToLittleInt32(unicodeInt); // To make it byte-order safe
NSString *unicodeString = [[NSString alloc] initWithBytes:&unicodeInt length:4 encoding:NSUTF32LittleEndianStringEncoding];
yourOutputLabel.text = unicodeString;
} else {
// Conversion failed, invalid input.
}
This works even with Unicodes > U+FFFF, such as 1F34C (thanks to R. Martinho Fernandes for his feedback).
Try changing the font of your UILable.
Actually some fonts can't display all unicode outputs!
This happened to me in Java Swing once!
I was trying to display a unicode string on a JLabel but the unicode string wasn't being displayed on JLablel.
Then I changed the font to Arial the unicode values got displayed!
So I'd suggest you to try changing the font from to Arial or some other font.
Hope this helps!
Problem is input should be char pointer
NSString *str = [NSString stringWithUTF8String:[self.textField.text UTF8String]];
m_CtrlLabel.text=str;