From 3d261d35fcd958488460b59baad6ae9eeb9bac66 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Thu, 14 Apr 2016 10:47:11 -0700 Subject: [PATCH] icu: add icu module * Moves transcode and normalize to buffer module statics * Moves getCharacterProperty and getColumnWidth to util --- doc/api/buffer.md | 21 ++ doc/api/util.md | 18 ++ lib/buffer.js | 3 + lib/internal/buffer.js | 96 ++++++++ lib/internal/readline.js | 172 ++++++++------ lib/util.js | 12 + node.gyp | 1 + src/node_buffer.cc | 17 -- src/node_constants.cc | 167 ++++++++++++++ src/node_i18n.cc | 473 ++++++++++++++++++++++++++++++++++++++ src/util.h | 26 +++ test/parallel/test-icu.js | 123 ++++++++++ tools/icu/icu-generic.gyp | 18 +- 13 files changed, 1048 insertions(+), 99 deletions(-) create mode 100644 lib/internal/buffer.js create mode 100644 test/parallel/test-icu.js diff --git a/doc/api/buffer.md b/doc/api/buffer.md index ac2c1e1b6752f0..8cebd8905ff296 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -2304,6 +2304,27 @@ added: v3.0.0 On 32-bit architectures, this value is `(2^30)-1` (~1GB). On 64-bit architectures, this value is `(2^31)-1` (~2GB). +## buffer.normalize(buf, form[, encoding]) + +* `buf` {Buffer} A `Buffer` instance +* `form` {String} A Unicode normalization form (one of: `'NFC'`, `'NFD'`, + `NFKC`, or `NFKD`) +* `encoding` {String} The source character encoding of the `buf`. Defaults to + `'utf8'` + +Performs Unicode Normalization to the `buf` and returns a new `Buffer` instance +containing the UTF-8 encoded results. Throws if the `form` does not specify a +valid Normalization form or if the normalization cannot be successfully applied. + +## buffer.transcode(buf, from_enc, to_enc) + +* `buf` {Buffer} A `Buffer` instance +* `from_enc` {string} The current encoding +* `to_enc` {string} The target encoding + +Re-encodes the given `Buffer` from one character encoding to another. Returns +a new `Buffer` instance. + ## Class: SlowBuffer