Skip to content

Commit

Permalink
docs(readme): fix wrong character codes
Browse files Browse the repository at this point in the history
  • Loading branch information
polygonplanet committed Oct 6, 2024
1 parent 1cb5821 commit 7a8328e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Since JavaScript string values are internally encoded as UTF-16 code units
they cannot directly handle other character encodings as strings. However, encoding.js overcomes this limitation by treating these encodings as arrays instead of strings,
enabling the conversion between different character sets.

Each character encoding is represented as an array of numbers corresponding to character code values, for example, `[130, 160]` represents "あ" in UTF-8.
Each character encoding is represented as an array of numbers corresponding to character code values, for example, `[130, 160]` represents "あ" in Shift_JIS.

The array of character codes used in its methods can also be utilized with TypedArray objects, such as `Uint8Array`, or with `Buffer` in Node.js.

Expand Down
2 changes: 1 addition & 1 deletion README_ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ encoding.js は、文字コードの変換や判定をする JavaScript ライ
`Shift_JIS``EUC-JP``ISO-2022-JP` など日本語の文字コードや、 `UTF-8``UTF-16` などの Unicode に対応しています。

JavaScript の文字列は内部で UTF-16 コードユニットとして符号化されるため、文字列のままでは他の文字コードを正しく扱えませんが ([参照: ECMAScript® 2019 Language Specification - 6.1.4 The String Type](https://www.ecma-international.org/ecma-262/10.0/index.html#sec-ecmascript-language-types-string-type))、encoding.js では文字列ではなく配列として扱い変換を実現しています。
各文字コードは、例えば `[130, 160]` (UTF-8の「あ」) などの文字コード値を持つ数値の配列として扱います。
各文字コードは、例えば `[130, 160]` (Shift_JIS の「あ」) などの文字コード値を持つ数値の配列として扱います。

また、encoding.js の各メソッドに渡す文字コードの配列は、`Uint8Array` などの TypedArray や Node.js の `Buffer` でも使えます。

Expand Down

0 comments on commit 7a8328e

Please sign in to comment.