我需要验证一些用户输入。据我所知,“en-US”是有效的HTTP区域设置,而“en_GB”则不是。有没有一种方法可以验证这个呢?
我需要验证一些用户输入。据我所知,“en-US”是有效的HTTP区域设置,而“en_GB”则不是。有没有一种方法可以验证这个呢?
The syntax and registry of HTTP language tags is the same as that defined by RFC 1766 1. In summary, a language tag is composed of 1 or more parts: A primary language tag and a possibly empty series of subtags:
language-tag = primary-tag *( "-" subtag ) primary-tag = 1*8ALPHA subtag = 1*8ALPHA
[...] where any two-letter primary-tag is an ISO-639 language abbreviation and any two-letter initial subtag is an ISO-3166 country code. (The last three tags above are not registered tags; all but the last are examples of tags which could be registered in future.)
这里是国家代码列表。当然,“GB”在列表中。
en-GB
是完全可以的,但en_GB
不行。