objective c - create NSString UTF8/Unicode character from int >127 -
i want create characters int values >127.
for example: calculate 133 , want character Å
or calculate 149 , want character Õ
(see http://www.utf8-chartable.de/unicode-utf8-table.pl?utf8=dec)
i use following code, not return correct character:
int pos = 133; nsstring *tf = [nsstring stringwithformat:@"%c", pos];
this because int >127 no regular ascii (which can done %c)
also %c not work.
do need encoding? or different operator in stringwithformat
? have looked @ cfstring
class, don't understand how can use here , if applicable.
what encoding using 133 encoded character Å?
from site
unicode utf-8 code point character (dec.) name u+00c5 Å 195 133 latin capital letter ring above
133 not valid value, value want is: 195 133 (two bytes). utf8 1 byte characters 127.
char utf8[2] = {195, 133}; nsstring *s = [nsstring stringwithutf8string:utf8]; nslog(@"s: '%@'", s);
nslog output:
s: 'Å'
the code point web page u+00c5, using utf32:
u_int32_t bytes = 0x00c5; nsstring *s = [[nsstring alloc] initwithbytes:&bytes length:4 encoding:nsutf32littleendianstringencoding]; nslog(@"s: '%@'", s);
nslog output:
s: 'Å'
Comments
Post a Comment