iOS本地化:具有“\uxxxx”形式的Unicode字符转义序列不起作用 [英] iOS Localization: Unicode character escape sequences, which have the form '\uxxxx' does not work

查看:376
本文介绍了iOS本地化:具有“\uxxxx”形式的Unicode字符转义序列不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在Localization.string文件中有键值对。

We have key-value pair in Localization.string file.

"spanish-key" = "Espa\u00f1ol";

当我们获取并分配给label时,app会将其显示为Espau00f1ol。

When we fetch and assign to label then app displays it as "Espau00f1ol".

不起作用。

self.label1.text= NSLocalizedString(@"spanish-key", nil);

工作 - 以所需格式显示。

self.label1.text= @"Espa\u00f1ol";

当我们使用

NSLocalizedString(@"spanish-key", nil)?

如果我们设置\U而不是\ u,那么它可以工作。

 "spanish-key" = "Espa\U00f1ol";

何时使用\ Uxxxx和\uxxxx?

推荐答案

NSString 文字和字符串文件使用不同转义规则

NSString literals and strings-files use different escaping rules.

NSString 文字使用与普通C字符串相同的转义序列,特别是
C99标准中定义的通用字符名称:

NSString literals use the same escape sequences as "normal" C-strings, in particular the "universal character names" defined in the C99 standard:

\unnnn      - the character whose four-digit short identifier is nnnn
\Unnnnnnnn  - the character whose eight-digit short identifier is nnnnnnnn



的字符

示例:

Example:

这篇关于iOS本地化:具有“\uxxxx”形式的Unicode字符转义序列不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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