发布于 2013-07-25 16:12:36
我认为IETF规范用于处理地区代码确实是业界的“最佳通用实践”,但肯定不是没有保持向后兼容性之类的妥协。由于最重要的国际化库和标准(Unicode、ICU)正在使用它,我仍然建议根据您的需要对其进行调整。
BCP47 47/ tag 5646 第4.4.1节建议使用35个字符的标签长度:
language = 8 ; longest allowed registered value
; longer than primary+extlang
; which requires 7 characters
script = 5 ; if not suppressed: see Section 4.1
region = 4 ; UN M.49 numeric region code
; ISO 3166-1 codes require 3
variant1 = 9 ; needs 'language' as a prefix
variant2 = 9 ; very rare, as it needs
; 'language-variant1' as a prefix
total = 35 characters
Figure 7: Derivation of the Limit on Tag Length但是,如果您只关心语言和脚本(而不是表示一些区域敏感数据(如日期和时间格式)的区域信息),那么您可以使用13个字符( max )。
实际上,大多数标记最终只能是语言的两个字符。我经常处理并需要脚本子标签的唯一常见示例是sr-Latn和sr-Cyrl (分别是用拉丁语或西里尔语编写的塞尔维亚语)、zh-Hant (繁体中文)和zh-Hans (简体中文)。另外,您很可能不需要这些变体,这意味着这些地区代码的大多数真实示例应该在17个字符的限制之下。
https://stackoverflow.com/questions/17848070
复制相似问题