I have a string that both have English letters and Japanese characters. I need to convert the Japanese characters to Unicode before transmitting the data to our server. I found a lot of topic converting to UTF-8 but I have not found anything when it comes to converting to Unicode.
Side note: I also notice that if I put the string in array and use NSLog to print the array, the Japanese text is printed in Unicode.
NSString *data = @"aさ";
NSArray *array = [NSArray arrayWithObjects: data, other data..., nil];
NSLog(@"%@", array);
This will print out: "a\U3055" for my string data inside the array.
NSData *dataenc = [data dataUsingEncoding:NSNonLossyASCIIStringEncoding];
NSString *encodevalue = [[NSString alloc]initWithData:dataenc encoding:NSUTF8StringEncoding];
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments