/**
* Unicode ---> UTF-8
*/
- (NSString*)replaceUnicode:(NSString*)aUnicodeString
{
NSString *tempStr1 = [aUnicodeString stringByReplacingOccurrencesOfString:@"\\\\u" withString:@"\\\\U"];
NSString *tempStr2 = [tempStr1 stringByReplacingOccurrencesOfString:@"\\"" withString:@"\\\\\\""];
NSString *tempStr3 = [[@"\\"" stringByAppendingString:tempStr2] stringByAppendingString:@"\\""];
NSData *tempData = [tempStr3 dataUsingEncoding:NSUTF8StringEncoding];
NSString* returnStr = [NSPropertyListSerialization propertyListFromData:tempData
mutabilityOption:NSPropertyListImmutable
format:NULL
errorDescription:NULL];
return [returnStr stringByReplacingOccurrencesOfString:@"\\\\r\\\\n" withString:@"\\n"];
}
/**
* utf8 ---> Unicode
*/
-(NSString *) utf8ToUnicode:(NSString *)string
{
NSUInteger length = [string length];
NSMutableString *s = [NSMutableString stringWithCapacity:0];
for (int i = 0;i < length; i++)
{
unichar _char = [string characterAtIndex:i];
[s appendFormat:@"\\\\u%x",_char];
}
return s;
}