Intl 国际化
Node.js 有很多特性可以让编写国际化程序变得更容易。 它们之中有一些是:
- ECMAScript 语言规范中的区域设置敏感或 Unicode 感知函数:
- ECMAScript 国际化 API 规范(又名 ECMA-402)中描述的所有功能:
Intl
对象- 像
String.prototype.localeCompare()
和Date.prototype.toLocaleString()
这样的区域敏感方法
- WHATWG 网址解析器的国际化域名(IDN)支持
require('buffer').transcode()
- 更准确的交互式解释器行编辑
require('util').TextDecoder
RegExp
Unicode 属性转义
Node.js has many features that make it easier to write internationalized programs. Some of them are:
- Locale-sensitive or Unicode-aware functions in the ECMAScript Language Specification:
- All functionality described in the ECMAScript Internationalization API
Specification (aka ECMA-402):
Intl
object- Locale-sensitive methods like
String.prototype.localeCompare()
andDate.prototype.toLocaleString()
- The WHATWG URL parser's internationalized domain names (IDNs) support
require('buffer').transcode()
- More accurate REPL line editing
require('util').TextDecoder
RegExp
Unicode Property Escapes
Node.js (and its underlying V8 engine) uses ICU to implement these features in native C/C++ code. However, some of them require a very large ICU data file in order to support all locales of the world. Because it is expected that most Node.js users will make use of only a small portion of ICU functionality, only a subset of the full ICU data set is provided by Node.js by default. Several options are provided for customizing and expanding the ICU data set either when building or running Node.js.