What are different between NSUTF8StringEncoding and NSUTF16StringEncoding?

1.7k views Asked by At

I am trying to understand about Encoding, as far i know utf-8 encode mean it t uses 8-bit blocks to represent a character.

NSString *NSUTF8Encoding = [[NSString alloc]initWithCString:"String" encoding:NSUTF8StringEncoding];

NSString *NSUTF16Encoding = [[NSString alloc]initWithCString:"String" encoding:NSUTF16StringEncoding];

NSLog(@"NSUTF8StringEncoding :%@",NSUTF8Encoding);

NSLog(@"NSUTF16StringEncoding :%@",NSUTF16Encoding);

its say : Incorrect NSStringEncoding value 0x0000 detected. Assuming NSASCIIStringEncoding. Will stop this compatiblity mapping behavior in the near future

what does it mean?

Thanks in advance.

1

There are 1 answers

3
Haroun SMIDA On
  • NSUTF8StringEncoding : An 8-bit representation of Unicode characters.
  • NSUTF16StringEncoding : An 16-bit representation of Unicode characters.

It relates to the amount of possible letters/numbers/symbols a character set can have. An 8-Bit character can only have 256 possible characters. Whereas a 16-bit can have 65,536.