用希伯来语ios加载Json

时间:2013-12-31 17:14:01

标签: ios objective-c json hebrew

我正在尝试加载此JSON:

  

{姓名:“希伯来字符串”,
    图片:“”,类别:“希伯来字符串”,
    成分:“希伯来字符串”,
    价格:“300”},.......

我的代码:

 NSURL *url = [[NSURL alloc] initWithString:@"url"];
 NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];

 AFJSONRequestOperation *operation = [AFJSONRequestOperation
 JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {

 NSLog(@"json = %@",JSON);       
 [[NSNotificationCenter defaultCenter]
                 addObserver:self
                 selector:@selector(dataretrived)
                 name:@"JsonFinishLoading"
                 object:nil];


 }failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {}

dta coms out scramble:

Category = "\U05db\U05e8\U05d9\U05da \U05d8\U05d5\U05e0\U05d4";  
        Image = "";  
        Ingredients = "\U05d8\U05d5\U05e0\U05d4,\U05e2\U05d2\U05d1\U05e0\U05d9\U05d4";  
        Name = "\U05db\U05e8\U05d9\U05da \U05d8\U05d5\U05e0\U05d4";  
        Price = 300;
    }....

如何转换数据以便正确显示?

1 个答案:

答案 0 :(得分:0)

我猜JSON字符串的ASCII字符'\'后跟'U'后跟'0'后跟'5'等。你需要将子字符串\ U05db转换为unichar 0x05db然后再做对于每个\ UXXXX。我在Xcode中使用希伯来语很多,当我为包含希伯来语的字符串执行NSLog时,它会很好地打印到控制台。