带有Unicode字符的iOS NSLog错误 [英] iOS NSLog error with Unicode characters

查看:105
本文介绍了带有Unicode字符的iOS NSLog错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我以下结果的差异原因吗?

Can anyone tell me the cause of the discrepancy for the following results ?

completionHandler:^(NSArray *placemarks, NSError *error) {
    NSLog(@"\n placemarks%@", placemarks);

结果:

placemarks(
"\U039b\U03b5\U03c9\U03c6\U03cc\U03c1\U03bf\U03c2 \U039a\U03cd\U03c0\U03c1\U03bf\U03c5 163, 16451 \U0391\U03c1\U03b3\U03c5\U03c1\U03bf\U03cd\U03c0\U03bf\U03bb\U03b7\U03c2, \U0395\U03bb\U03bb\U03ac\U03c2 @ <+37.90085408,+23.75654648> +/- 100.00m, region (identifier <+37.90085408,+23.75654648> radius 141.62) <+37.90085408,+23.75654648> radius 141.62m"
)

for(id object in placemarks ) {NSLog(@"%@ \n", object);}

结果

2012-09-14 13:08:23.493 ΑΦΜ[1390:c07] Λεωφόρος Κύπρου 163, 16451 Αργυρούπολης, Ελλάς @ <+37.90085408,+23.75654648> +/- 100.00m, region (identifier <+37.90085408,+23.75654648> radius 141.62) <+37.90085408,+23.75654648> radius 141.62m 

谢谢

推荐答案

有趣的:)

%@ 传递到 NSLog 的格式字符串只是对一个对象'调用 description

Passing %@ into NSLog's format string just means 'call description on an object'.

它看起来像描述 NSArray 处理unicode字符与描述不同

It looks like description on NSArray deals with unicode characters differently than the description on each object.

但是,我怀疑 NSArray 上的描述方法只调用每个对象的描述它包含的对象,然后由于某种原因,我不是100%肯定,在将它们转储到 NSLog 之前对它们进行编码。

However, I suspect that the description method on NSArray just calls description on each of the objects it contains and then, for some reason I'm not 100% sure about, is encoding them before dumping them out to NSLog.

这篇关于带有Unicode字符的iOS NSLog错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆