Intl 国际化
Node.js 有很多特性可以让编写国际化程序变得更容易。 它们之中有一些是:
- ECMAScript 语言规范中的区域设置敏感或 Unicode 感知函数:
- ECMAScript 国际化 API 规范(又名 ECMA-402)中描述的所有功能:
Intl
对象- 像
String.prototype.localeCompare()
和Date.prototype.toLocaleString()
这样的区域敏感方法
- WHATWG 网址解析器的国际化域名(IDN)支持
require('node:buffer').transcode()
- 更准确的交互式解释器行编辑
require('node:util').TextDecoder
RegExp
Unicode 属性转义
Node.js 和底层 V8 引擎使用 Unicode 国际组件(ICU) 在原生 C/C++ 代码中实现这些特性。 默认情况下,Node.js 提供了完整的 ICU 数据集。 但是,由于 ICU 数据文件的大小,在构建或运行 Node.js 时提供了几个用于自定义 ICU 数据集的选项。
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('node:buffer').transcode()
- More accurate REPL line editing
require('node:util').TextDecoder
RegExp
Unicode Property Escapes
Node.js and the underlying V8 engine use International Components for Unicode (ICU) to implement these features in native C/C++ code. The full ICU data set is provided by Node.js by default. However, due to the size of the ICU data file, several options are provided for customizing the ICU data set either when building or running Node.js.