从 objective c 发送到 javascript 的越南语文本被扭曲
vietnamese text send to javascript from objective c gets distorted
我正在将 json 字符串从 Objective C 发送到 javascript 代码。
但是文本字符串被扭曲了
{"data":{"type":"new","id":"xyz","text":"Thêm nhóm ês","userid":["16"]},"type":"hello","action":"update"}
越南语字符串 Thêm nhóm ês 已更改
我是如何实现的:
@try
{
NSData *utf8Data = [data dataUsingEncoding:NSUTF8StringEncoding];
NSString *encodedString = [utf8Data base64EncodedStringWithOptions:0];
NSString *jsString = [NSString stringWithFormat:@"javascript:notifyJSObservers('%@','%@')",eventName, encodedString];
[self.webView stringByEvaluatingJavaScriptFromString:jsString];
}
@catch (NSException *exception)
{
NSLog(@"JS issues :: %@",exception.reason);
}
谁能解释一下这个问题。
@try
{
NSData *nsdata = [data dataUsingEncoding:NSUTF8StringEncoding];
NSString *base64Encoded = [nsdata base64EncodedStringWithOptions:0];
int code = 1004;
NSString *jsString = [NSString stringWithFormat:@"javascript:handleResponseFromNative('%d','%@')",code, base64Encoded];
[self.previewWebView performSelector:@selector(stringByEvaluatingJavaScriptFromString:) withObject:jsString afterDelay:0.5];
}
@catch (NSException *exception)
{
NSLog(@"JS issues :: %@",exception.reason);
}
我正在将 json 字符串从 Objective C 发送到 javascript 代码。 但是文本字符串被扭曲了
{"data":{"type":"new","id":"xyz","text":"Thêm nhóm ês","userid":["16"]},"type":"hello","action":"update"}
越南语字符串 Thêm nhóm ês 已更改
我是如何实现的:
@try
{
NSData *utf8Data = [data dataUsingEncoding:NSUTF8StringEncoding];
NSString *encodedString = [utf8Data base64EncodedStringWithOptions:0];
NSString *jsString = [NSString stringWithFormat:@"javascript:notifyJSObservers('%@','%@')",eventName, encodedString];
[self.webView stringByEvaluatingJavaScriptFromString:jsString];
}
@catch (NSException *exception)
{
NSLog(@"JS issues :: %@",exception.reason);
}
谁能解释一下这个问题。
@try
{
NSData *nsdata = [data dataUsingEncoding:NSUTF8StringEncoding];
NSString *base64Encoded = [nsdata base64EncodedStringWithOptions:0];
int code = 1004;
NSString *jsString = [NSString stringWithFormat:@"javascript:handleResponseFromNative('%d','%@')",code, base64Encoded];
[self.previewWebView performSelector:@selector(stringByEvaluatingJavaScriptFromString:) withObject:jsString afterDelay:0.5];
}
@catch (NSException *exception)
{
NSLog(@"JS issues :: %@",exception.reason);
}