ja-char-check 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/LICENSE +21 -0
- package/LICENSE-Unicode.txt +39 -0
- package/README.en.md +73 -0
- package/README.md +92 -2
- package/dist/bytes.d.ts +10 -0
- package/dist/bytes.js +47 -0
- package/dist/characters.d.ts +17 -0
- package/dist/characters.js +18 -0
- package/dist/check.d.ts +38 -0
- package/dist/check.js +75 -0
- package/dist/counts.d.ts +6 -0
- package/dist/counts.js +13 -0
- package/dist/encoding.d.ts +15 -0
- package/dist/encoding.js +98 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +5 -0
- package/dist/legacy-data.d.ts +14 -0
- package/dist/legacy-data.js +297 -0
- package/dist/replacements.d.ts +23 -0
- package/dist/replacements.js +56 -0
- package/docs/api.md +97 -0
- package/docs/mappings.md +69 -0
- package/package.json +43 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.2.0 — Unreleased
|
|
4
|
+
|
|
5
|
+
- Report `basis: "width_variant"` for the `¥` → `¥` replacement and label it as a fullwidth yen sign in the demo. Consumers that branch on `ReplacementCandidate.basis` should handle the new value.
|
|
6
|
+
- Show the Shift_JIS and CP932 backslash byte counts in both READMEs and the demo. Document how `truncateByBytes` reports unsupported characters beyond the byte limit.
|
|
7
|
+
|
|
8
|
+
## 0.1.1
|
|
9
|
+
|
|
10
|
+
- Link all seven related projects to their public repositories and live demos from the Japanese and English READMEs and the demo.
|
|
11
|
+
- Link the published ja-char-check demo from both READMEs and update the CDN examples for 0.1.1.
|
|
12
|
+
|
|
13
|
+
## 0.1.0
|
|
14
|
+
|
|
15
|
+
- Add Unicode, UTF-8, Shift_JIS, CP932 / Windows-31J and JIS X 0208 checks with UTF-16 and code-point positions.
|
|
16
|
+
- Classify CP932 extension areas, private-use code points, controls, invisible characters, variation selectors, combining marks and compatibility ideographs. Allow custom character policies.
|
|
17
|
+
- Count UTF-16 code units, code points, grapheme clusters and encoded bytes. Truncate at grapheme or code-point boundaries and report the first encoding failure.
|
|
18
|
+
- Offer mapping-based replacement candidates with per-occurrence approval.
|
|
19
|
+
- Include reproducible mapping generation, an interactive GitHub Pages demo and an npm tarball consumer check.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Fusai Hanabi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
UNICODE LICENSE V3
|
|
2
|
+
|
|
3
|
+
COPYRIGHT AND PERMISSION NOTICE
|
|
4
|
+
|
|
5
|
+
Copyright © 1991-2026 Unicode, Inc.
|
|
6
|
+
|
|
7
|
+
NOTICE TO USER: Carefully read the following legal agreement. BY
|
|
8
|
+
DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING DATA FILES, AND/OR
|
|
9
|
+
SOFTWARE, YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE
|
|
10
|
+
TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU DO NOT AGREE, DO NOT
|
|
11
|
+
DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE THE DATA FILES OR SOFTWARE.
|
|
12
|
+
|
|
13
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
|
14
|
+
copy of data files and any associated documentation (the "Data Files") or
|
|
15
|
+
software and any associated documentation (the "Software") to deal in the
|
|
16
|
+
Data Files or Software without restriction, including without limitation
|
|
17
|
+
the rights to use, copy, modify, merge, publish, distribute, and/or sell
|
|
18
|
+
copies of the Data Files or Software, and to permit persons to whom the
|
|
19
|
+
Data Files or Software are furnished to do so, provided that either (a)
|
|
20
|
+
this copyright and permission notice appear with all copies of the Data
|
|
21
|
+
Files or Software, or (b) this copyright and permission notice appear in
|
|
22
|
+
associated Documentation.
|
|
23
|
+
|
|
24
|
+
THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
|
|
25
|
+
KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
26
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
27
|
+
THIRD PARTY RIGHTS.
|
|
28
|
+
|
|
29
|
+
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE
|
|
30
|
+
BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES,
|
|
31
|
+
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
|
32
|
+
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
|
33
|
+
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA
|
|
34
|
+
FILES OR SOFTWARE.
|
|
35
|
+
|
|
36
|
+
Except as contained in this notice, the name of a copyright holder shall
|
|
37
|
+
not be used in advertising or otherwise to promote the sale, use or other
|
|
38
|
+
dealings in these Data Files or Software without prior written
|
|
39
|
+
authorization of the copyright holder.
|
package/README.en.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# ja-char-check
|
|
2
|
+
|
|
3
|
+
[日本語](README.md) · [Live demo](https://fusaihanabi.github.io/ja-char-check/) · [API](docs/api.md) · [Related libraries](#related-libraries) · [Mapping sources and profiles](docs/mappings.md) · [Changelog](CHANGELOG.md)
|
|
4
|
+
|
|
5
|
+
TypeScript checks for Japanese character repertoires, encoding compatibility, and byte limits in forms, CSV exports, and legacy integrations. Part of the Fusai Hanabi OSS series. The package provides ES modules and type declarations for browsers and Node.js with zero runtime dependencies.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
After npm publication, install with `npm install ja-char-check`. To try the project before publication, run `npm ci`, `npm run build`, and `npm pack` in this repository, then install the resulting `.tgz` in your project.
|
|
10
|
+
|
|
11
|
+
After npm publication, a browser can import the ESM build from `https://unpkg.com/ja-char-check@0.2.0/dist/index.js` or `https://cdn.jsdelivr.net/npm/ja-char-check@0.2.0/dist/index.js` in a `type="module"` script. Pin the published version you use in the URL.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import {
|
|
17
|
+
checkCharacters, getByteLength, isEncodable, truncateByBytes,
|
|
18
|
+
suggestReplacements, applyReplacements,
|
|
19
|
+
} from "ja-char-check"
|
|
20
|
+
|
|
21
|
+
isEncodable("髙橋", "shift_jis") // false
|
|
22
|
+
isEncodable("髙橋", "cp932") // true
|
|
23
|
+
getByteLength("A髙橋", "cp932") // 5
|
|
24
|
+
truncateByBytes("A髙橋", 4, "cp932") // "A髙"
|
|
25
|
+
|
|
26
|
+
const check = checkCharacters("受付\n①", {
|
|
27
|
+
encoding: "windows-31j",
|
|
28
|
+
rejectCategories: ["control"],
|
|
29
|
+
})
|
|
30
|
+
// check.encodable is true; check.ok is false.
|
|
31
|
+
|
|
32
|
+
const input = "1日〜3日 𠮷田"
|
|
33
|
+
const options = { encoding: "cp932" } as const
|
|
34
|
+
const suggestions = suggestReplacements(input, options)
|
|
35
|
+
// Offers "~" for "〜" and explains the source mapping.
|
|
36
|
+
|
|
37
|
+
// After the user approves the candidate at this position:
|
|
38
|
+
const index = suggestions[0].utf16Index
|
|
39
|
+
applyReplacements(input, options, (item) => item.utf16Index === index ? "~" : undefined)
|
|
40
|
+
// "1日~3日 𠮷田"
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`unicode` checks Unicode scalar values. `jis-x-0208` checks character-set membership. The byte APIs accept `utf-8`, `shift_jis`, `cp932`, and `windows-31j` (an alias of `cp932`). Each legacy profile requires an exact code-point round trip. Byte measurement throws `CharacterEncodingError` for lossy mappings, unsupported characters, or lone surrogates. Truncation respects grapheme clusters by default. Grapheme counting and truncation at a grapheme boundary use `Intl.Segmenter`.
|
|
44
|
+
|
|
45
|
+
The backslash `\` (U+005C) takes two bytes under this library's `shift_jis` profile and one byte under `cp932`. Choose a profile that matches your output encoder's mapping. [Mapping sources and profiles](docs/mappings.md)
|
|
46
|
+
|
|
47
|
+
Character positions are zero-based UTF-16 offsets and code-point indices. Replacements require per-occurrence approval and are limited to documented legacy mapping variants and selected Unicode compatibility forms. Name and place-name ideographs are preserved.
|
|
48
|
+
|
|
49
|
+
## Related libraries
|
|
50
|
+
|
|
51
|
+
For Japanese forms, normalize the input and validate each field, then use `ja-char-check` to check encoding compatibility and byte limits before saving or exporting to CSV.
|
|
52
|
+
|
|
53
|
+
| Library | Use it for | Links |
|
|
54
|
+
| --- | --- | --- |
|
|
55
|
+
| `normalize-ja-input` | Normalize character width, spaces, hyphens, and other input variants | [GitHub](https://github.com/fusaihanabi/normalize-ja-input) · [Live demo](https://fusaihanabi.github.io/normalize-ja-input/) |
|
|
56
|
+
| `ja-form-validators` | Validate Japanese postal codes, phone numbers, and furigana | [GitHub](https://github.com/fusaihanabi/ja-form-validators) · [Live demo](https://fusaihanabi.github.io/ja-form-validators/) |
|
|
57
|
+
| `tiny-ja-date` | Format Japanese dates and relative dates and calculate business days | [GitHub](https://github.com/fusaihanabi/tiny-ja-date) · [Live demo](https://fusaihanabi.github.io/tiny-ja-date/) |
|
|
58
|
+
| `ja-ime-utils` | Distinguish IME confirmation from form submission and process committed input | [GitHub](https://github.com/fusaihanabi/ja-ime-utils) · [Live demo](https://fusaihanabi.github.io/ja-ime-utils/) |
|
|
59
|
+
| `ja-input-mask` | Format postal codes, phone numbers, and dates as users type, with Japanese IME support | [GitHub](https://github.com/fusaihanabi/ja-input-mask) · [Live demo](https://fusaihanabi.github.io/ja-input-mask/) |
|
|
60
|
+
| `tiny-ja-money` | Parse and format whole yen and calculate tax and allocations | [GitHub](https://github.com/fusaihanabi/tiny-ja-money) · [Live demo](https://fusaihanabi.github.io/tiny-ja-money/) |
|
|
61
|
+
| `ja-zengin-utils` | Validate Zengin kana and read or write 120-byte fixed-width bulk transfer files | [GitHub](https://github.com/fusaihanabi/ja-zengin-utils) · [Live demo](https://fusaihanabi.github.io/ja-zengin-utils/) |
|
|
62
|
+
|
|
63
|
+
[Fusai Hanabi OSS](https://dl.fusai-hanabi.com/)
|
|
64
|
+
|
|
65
|
+
## Demo and release checks
|
|
66
|
+
|
|
67
|
+
Run `npm ci`, `npm run typecheck`, `npm test`, `npm run build:demo`, and `npm run check:package`. The package check packs and installs a real tarball in an offline temporary consumer, then checks its ESM entry point and TypeScript declarations.
|
|
68
|
+
|
|
69
|
+
Serve `docs/` over HTTP to use the interactive demo. For example, run `python -m http.server 8000 --bind 127.0.0.1 --directory docs` and open `http://127.0.0.1:8000/`. The same directory is ready for GitHub Pages. Rebuild and check the generated browser modules with `npm run build:demo` and `npm run check:demo`.
|
|
70
|
+
|
|
71
|
+
## License
|
|
72
|
+
|
|
73
|
+
Library and demo code use the [MIT License](LICENSE). Generated mapping data uses the [Unicode License v3](LICENSE-Unicode.txt). See the [mapping sources and generation instructions](docs/mappings.md).
|
package/README.md
CHANGED
|
@@ -1,3 +1,93 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ja-char-check
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[English](README.en.md) · [ライブデモ](https://fusaihanabi.github.io/ja-char-check/) · [API](docs/api.md) · [関連ライブラリ](#関連ライブラリ) · [文字コードとマッピング](docs/mappings.md) · [変更履歴](CHANGELOG.md)
|
|
4
|
+
|
|
5
|
+
日本語フォームやCSV、レガシーシステム連携向けの、文字集合・文字コード互換性とバイト数を検査するTypeScriptライブラリです。Fusai Hanabi OSSシリーズの一つです。ブラウザとNode.jsで利用でき、ESM、型定義、ランタイム依存ゼロに対応します。
|
|
6
|
+
|
|
7
|
+
## インストール
|
|
8
|
+
|
|
9
|
+
npm公開後は `npm install ja-char-check` で導入できます。公開前に試す場合は、このリポジトリで `npm ci`、`npm run build`、`npm pack` を実行し、利用側のプロジェクトで生成された `.tgz` をインストールしてください。
|
|
10
|
+
|
|
11
|
+
ブラウザで直接読み込む場合は、npm公開後に `https://unpkg.com/ja-char-check@0.2.0/dist/index.js` または `https://cdn.jsdelivr.net/npm/ja-char-check@0.2.0/dist/index.js` を、`type="module"` のスクリプトからインポートできます。URLのバージョンは利用する公開版に合わせてください。
|
|
12
|
+
|
|
13
|
+
## 使い方
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import {
|
|
17
|
+
checkCharacters, findUnsupportedChars, getByteLength, isEncodable, truncateByBytes,
|
|
18
|
+
} from "ja-char-check"
|
|
19
|
+
|
|
20
|
+
isEncodable("髙橋", "shift_jis") // false
|
|
21
|
+
isEncodable("髙橋", "cp932") // true
|
|
22
|
+
getByteLength("A髙橋", "cp932") // 5
|
|
23
|
+
truncateByBytes("A髙橋", 4, "cp932") // "A髙"
|
|
24
|
+
|
|
25
|
+
findUnsupportedChars("A𠮷", "cp932")[0]
|
|
26
|
+
// { character: "𠮷", codePoint: 0x20BB7, utf16Index: 1, codePointIndex: 1,
|
|
27
|
+
// encoding: "cp932", reason: "unsupported_character", severity: "error" }
|
|
28
|
+
|
|
29
|
+
const result = checkCharacters("受付\n①", {
|
|
30
|
+
encoding: "windows-31j",
|
|
31
|
+
rejectCategories: ["control"],
|
|
32
|
+
})
|
|
33
|
+
// result.encodable === true、result.ok === false
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
`unicode` はUnicodeスカラー値、`jis-x-0208` は文字集合への所属を確認します。`utf-8`、`shift_jis`、`cp932`(別名 `windows-31j`)ではバイト数も計算できます。Shift_JISとCP932は別のマッピングを使います。判定では元のコードポイントへの往復を要求し、未対応文字や不正なサロゲートを含む入力のバイト測定では `CharacterEncodingError` が発生します。切り詰めは既定で書記素クラスタ境界を使います。書記素クラスタを扱う機能には `Intl.Segmenter` が必要です。
|
|
37
|
+
|
|
38
|
+
バックスラッシュ `\`(U+005C)は、このライブラリの `shift_jis` では2バイト、`cp932` では1バイトです。連携先のエンコーダーが使うマッピングに合わせて判定プロファイルを選んでください。 [文字コードとマッピング](docs/mappings.md)
|
|
39
|
+
|
|
40
|
+
## 置換候補を表示して承認する
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import { applyReplacements, suggestReplacements } from "ja-char-check"
|
|
44
|
+
|
|
45
|
+
const input = "納期は1日〜3日、担当は𠮷田"
|
|
46
|
+
const options = { encoding: "cp932" } as const
|
|
47
|
+
const suggestions = suggestReplacements(input, options)
|
|
48
|
+
// 「〜」に「~」を提案。候補には根拠と元の文字位置が付く。
|
|
49
|
+
|
|
50
|
+
// 利用者がこの位置で「~」を選んだ場合
|
|
51
|
+
const selectedIndex = suggestions[0].utf16Index
|
|
52
|
+
const edited = applyReplacements(input, options, ({ utf16Index }) =>
|
|
53
|
+
utf16Index === selectedIndex ? "~" : undefined,
|
|
54
|
+
)
|
|
55
|
+
// "納期は1日~3日、担当は𠮷田"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
候補はマッピング差分と一部のUnicode互換分解に限ります。人名・地名の異体字を候補に加えることはありません。置換後の文字列も、必要に応じて再検査できます。
|
|
59
|
+
|
|
60
|
+
## 関連ライブラリ
|
|
61
|
+
|
|
62
|
+
日本語フォームでは、入力の表記を整え、項目の形式を検証したうえで、保存やCSV出力の前に `ja-char-check` で文字コードとバイト数を確認できます。
|
|
63
|
+
|
|
64
|
+
| ライブラリ | 用途 | リンク |
|
|
65
|
+
| --- | --- | --- |
|
|
66
|
+
| `normalize-ja-input` | 全角・半角、スペース、ハイフンなどの表記ゆれを正規化 | [GitHub](https://github.com/fusaihanabi/normalize-ja-input) · [ライブデモ](https://fusaihanabi.github.io/normalize-ja-input/) |
|
|
67
|
+
| `ja-form-validators` | 郵便番号・電話番号・フリガナなど、日本向けフォームの項目を検証 | [GitHub](https://github.com/fusaihanabi/ja-form-validators) · [ライブデモ](https://fusaihanabi.github.io/ja-form-validators/) |
|
|
68
|
+
| `tiny-ja-date` | 日本語の日付表示、相対日付、営業日計算 | [GitHub](https://github.com/fusaihanabi/tiny-ja-date) · [ライブデモ](https://fusaihanabi.github.io/tiny-ja-date/) |
|
|
69
|
+
| `ja-ime-utils` | 日本語IMEの変換確定とフォーム送信を区別し、確定した入力を処理 | [GitHub](https://github.com/fusaihanabi/ja-ime-utils) · [ライブデモ](https://fusaihanabi.github.io/ja-ime-utils/) |
|
|
70
|
+
| `ja-input-mask` | IMEを考慮しながら郵便番号、電話番号、日付などを入力欄で整形 | [GitHub](https://github.com/fusaihanabi/ja-input-mask) · [ライブデモ](https://fusaihanabi.github.io/ja-input-mask/) |
|
|
71
|
+
| `tiny-ja-money` | 円額の読み取り・表示、税額や按分の計算 | [GitHub](https://github.com/fusaihanabi/tiny-ja-money) · [ライブデモ](https://fusaihanabi.github.io/tiny-ja-money/) |
|
|
72
|
+
| `ja-zengin-utils` | 全銀カナの検証、総合振込の120バイト固定長ファイルの生成・解析 | [GitHub](https://github.com/fusaihanabi/ja-zengin-utils) · [ライブデモ](https://fusaihanabi.github.io/ja-zengin-utils/) |
|
|
73
|
+
|
|
74
|
+
[Fusai Hanabi OSS公式サイト](https://dl.fusai-hanabi.com/)
|
|
75
|
+
|
|
76
|
+
## デモと開発
|
|
77
|
+
|
|
78
|
+
```sh
|
|
79
|
+
npm ci
|
|
80
|
+
npm run typecheck
|
|
81
|
+
npm test
|
|
82
|
+
npm run build:demo
|
|
83
|
+
npm run check:demo
|
|
84
|
+
npm run check:package
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
`docs/` を静的HTTPサーバーで開くと、文字コードやバイト上限を切り替え、文字位置、分類、置換候補を確認できます。Pythonが使える環境では、リポジトリのルートから `python -m http.server 8000 --bind 127.0.0.1 --directory docs` を実行し、ブラウザで `http://127.0.0.1:8000/` を開きます。GitHub Pagesでは `main` ブランチの `/docs` を公開元に指定できます。ライブラリ変更時は `npm run build:demo` で配下の配信用モジュールを更新します。
|
|
88
|
+
|
|
89
|
+
`check:package` は `npm pack` で実物のtarballを生成し、オフラインで一時プロジェクトへインストールして、パッケージ名からのESM読み込みとTypeScript型解決を検証します。GitHub Actionsの確認対象はWindows・Ubuntu上のNode.js 22、24、26です。
|
|
90
|
+
|
|
91
|
+
## ライセンス
|
|
92
|
+
|
|
93
|
+
ライブラリとデモのコードは [MIT](LICENSE)、生成マッピングデータは [Unicode License v3](LICENSE-Unicode.txt) です。出典と再生成手順は [文字コードとマッピング](docs/mappings.md) を参照してください。
|
package/dist/bytes.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ByteEncoding, EncodingIssue } from "./encoding.js";
|
|
2
|
+
export declare class CharacterEncodingError extends Error {
|
|
3
|
+
readonly issue: EncodingIssue;
|
|
4
|
+
constructor(issue: EncodingIssue);
|
|
5
|
+
}
|
|
6
|
+
export declare function getByteLength(value: string, encoding: ByteEncoding): number;
|
|
7
|
+
export interface TruncateOptions {
|
|
8
|
+
boundary?: "grapheme" | "code-point";
|
|
9
|
+
}
|
|
10
|
+
export declare function truncateByBytes(value: string, maxBytes: number, encoding: ByteEncoding, options?: TruncateOptions): string;
|
package/dist/bytes.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { iterateCharacters, segmentGraphemes } from "./characters.js";
|
|
2
|
+
import { encodingIssue, measureCharacter, validateEncoding } from "./encoding.js";
|
|
3
|
+
export class CharacterEncodingError extends Error {
|
|
4
|
+
constructor(issue) {
|
|
5
|
+
const code = issue.codePoint.toString(16).toUpperCase().padStart(4, "0");
|
|
6
|
+
super(`${issue.encoding}: ${issue.reason} at UTF-16 index ${issue.utf16Index} (U+${code})`);
|
|
7
|
+
this.name = "CharacterEncodingError";
|
|
8
|
+
this.issue = issue;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function validateByteEncoding(encoding) {
|
|
12
|
+
validateEncoding(encoding);
|
|
13
|
+
if (encoding === "unicode" || encoding === "jis-x-0208") {
|
|
14
|
+
throw new RangeError(`Byte measurement requires a concrete encoding: ${encoding}`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function measureValue(value, encoding, maxBytes) {
|
|
18
|
+
let byteLength = 0;
|
|
19
|
+
let prefixEnd = 0;
|
|
20
|
+
for (const position of iterateCharacters(value)) {
|
|
21
|
+
const size = measureCharacter(position.codePoint, encoding);
|
|
22
|
+
if (typeof size !== "number")
|
|
23
|
+
throw new CharacterEncodingError(encodingIssue(position, encoding, size));
|
|
24
|
+
byteLength += size;
|
|
25
|
+
if (byteLength <= maxBytes)
|
|
26
|
+
prefixEnd = position.utf16Index + position.character.length;
|
|
27
|
+
}
|
|
28
|
+
return { byteLength, prefixEnd };
|
|
29
|
+
}
|
|
30
|
+
export function getByteLength(value, encoding) {
|
|
31
|
+
validateByteEncoding(encoding);
|
|
32
|
+
return measureValue(value, encoding, Infinity).byteLength;
|
|
33
|
+
}
|
|
34
|
+
export function truncateByBytes(value, maxBytes, encoding, options = {}) {
|
|
35
|
+
validateByteEncoding(encoding);
|
|
36
|
+
if (!Number.isSafeInteger(maxBytes) || maxBytes < 0) {
|
|
37
|
+
throw new RangeError("maxBytes must be a non-negative safe integer");
|
|
38
|
+
}
|
|
39
|
+
const { boundary = "grapheme" } = options;
|
|
40
|
+
if (boundary !== "grapheme" && boundary !== "code-point")
|
|
41
|
+
throw new RangeError(`Unknown boundary: ${boundary}`);
|
|
42
|
+
const { prefixEnd } = measureValue(value, encoding, maxBytes);
|
|
43
|
+
if (prefixEnd === 0 || prefixEnd === value.length || boundary === "code-point")
|
|
44
|
+
return value.slice(0, prefixEnd);
|
|
45
|
+
// The containing cluster starts at the last grapheme boundary at or before prefixEnd.
|
|
46
|
+
return value.slice(0, segmentGraphemes(value).containing(prefixEnd).index);
|
|
47
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface CharacterPosition {
|
|
2
|
+
character: string;
|
|
3
|
+
codePoint: number;
|
|
4
|
+
utf16Index: number;
|
|
5
|
+
codePointIndex: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function iterateCharacters(value: string): IterableIterator<CharacterPosition>;
|
|
8
|
+
export declare function isSurrogate(codePoint: number): boolean;
|
|
9
|
+
interface GraphemeSegments extends Iterable<{
|
|
10
|
+
index: number;
|
|
11
|
+
}> {
|
|
12
|
+
containing(index: number): {
|
|
13
|
+
index: number;
|
|
14
|
+
} | undefined;
|
|
15
|
+
}
|
|
16
|
+
export declare function segmentGraphemes(value: string): GraphemeSegments;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function* iterateCharacters(value) {
|
|
2
|
+
let utf16Index = 0;
|
|
3
|
+
let codePointIndex = 0;
|
|
4
|
+
for (const character of value) {
|
|
5
|
+
yield { character, codePoint: character.codePointAt(0), utf16Index, codePointIndex };
|
|
6
|
+
utf16Index += character.length;
|
|
7
|
+
codePointIndex++;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export function isSurrogate(codePoint) {
|
|
11
|
+
return codePoint >= 0xd800 && codePoint <= 0xdfff;
|
|
12
|
+
}
|
|
13
|
+
export function segmentGraphemes(value) {
|
|
14
|
+
if (typeof Intl === "undefined" || typeof Intl.Segmenter !== "function") {
|
|
15
|
+
throw new Error("Grapheme segmentation requires Intl.Segmenter");
|
|
16
|
+
}
|
|
17
|
+
return new Intl.Segmenter(undefined, { granularity: "grapheme" }).segment(value);
|
|
18
|
+
}
|
package/dist/check.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type CharacterPosition } from "./characters.js";
|
|
2
|
+
import type { CharacterEncoding, EncodingIssue } from "./encoding.js";
|
|
3
|
+
export type CharacterCategory = "control" | "invisible" | "variation_selector" | "combining_mark" | "vendor_extension" | "private_use" | "halfwidth_kana" | "compatibility_ideograph";
|
|
4
|
+
export type Cp932Extension = "nec_special" | "nec_selected_ibm" | "ibm" | "user_defined" | "microsoft_single_byte";
|
|
5
|
+
export interface CharacterClassification {
|
|
6
|
+
character: string;
|
|
7
|
+
codePoint: number;
|
|
8
|
+
isUnicodeScalar: boolean;
|
|
9
|
+
categories: CharacterCategory[];
|
|
10
|
+
cp932Extensions: Cp932Extension[];
|
|
11
|
+
}
|
|
12
|
+
export declare function classifyCharacter(character: string): CharacterClassification;
|
|
13
|
+
export type AllowedCharacters = string | ReadonlySet<string> | ((position: Readonly<CharacterPosition>) => boolean);
|
|
14
|
+
export interface CheckCharactersOptions {
|
|
15
|
+
encoding?: CharacterEncoding;
|
|
16
|
+
allowedCharacters?: AllowedCharacters;
|
|
17
|
+
reportCategories?: readonly CharacterCategory[];
|
|
18
|
+
rejectCategories?: readonly CharacterCategory[];
|
|
19
|
+
}
|
|
20
|
+
export interface DisallowedCharacterIssue extends CharacterPosition {
|
|
21
|
+
reason: "disallowed_character";
|
|
22
|
+
severity: "error";
|
|
23
|
+
encoding: CharacterEncoding;
|
|
24
|
+
}
|
|
25
|
+
export interface CharacterCategoryIssue extends CharacterPosition {
|
|
26
|
+
reason: CharacterCategory;
|
|
27
|
+
severity: "warning" | "error";
|
|
28
|
+
encoding: CharacterEncoding;
|
|
29
|
+
cp932Extensions: Cp932Extension[];
|
|
30
|
+
}
|
|
31
|
+
export type CharacterIssue = EncodingIssue | DisallowedCharacterIssue | CharacterCategoryIssue;
|
|
32
|
+
export interface CheckCharactersResult {
|
|
33
|
+
ok: boolean;
|
|
34
|
+
encodable: boolean;
|
|
35
|
+
encoding: CharacterEncoding;
|
|
36
|
+
issues: CharacterIssue[];
|
|
37
|
+
}
|
|
38
|
+
export declare function checkCharacters(value: string, options?: CheckCharactersOptions): CheckCharactersResult;
|
package/dist/check.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { isSurrogate, iterateCharacters } from "./characters.js";
|
|
2
|
+
import { encodingIssue, getLegacyFlags, measureCharacter, validateEncoding } from "./encoding.js";
|
|
3
|
+
import { legacyFlags } from "./legacy-data.js";
|
|
4
|
+
const cp932Areas = [
|
|
5
|
+
[legacyFlags.necSpecial, "nec_special"],
|
|
6
|
+
[legacyFlags.necSelectedIbm, "nec_selected_ibm"],
|
|
7
|
+
[legacyFlags.ibm, "ibm"],
|
|
8
|
+
[legacyFlags.userDefined, "user_defined"],
|
|
9
|
+
[legacyFlags.microsoftSingle, "microsoft_single_byte"],
|
|
10
|
+
];
|
|
11
|
+
function classify(position) {
|
|
12
|
+
const { character, codePoint } = position;
|
|
13
|
+
const categories = [];
|
|
14
|
+
if (/\p{Cc}/u.test(character))
|
|
15
|
+
categories.push("control");
|
|
16
|
+
if (/[\p{Cf}\p{Default_Ignorable_Code_Point}\u2028\u2029]/u.test(character))
|
|
17
|
+
categories.push("invisible");
|
|
18
|
+
if (/\p{Variation_Selector}/u.test(character))
|
|
19
|
+
categories.push("variation_selector");
|
|
20
|
+
if (/\p{M}/u.test(character))
|
|
21
|
+
categories.push("combining_mark");
|
|
22
|
+
if (/\p{Co}/u.test(character))
|
|
23
|
+
categories.push("private_use");
|
|
24
|
+
if (codePoint >= 0xff61 && codePoint <= 0xff9f)
|
|
25
|
+
categories.push("halfwidth_kana");
|
|
26
|
+
if (/\p{Assigned}/u.test(character) && (codePoint >= 0xf900 && codePoint <= 0xfaff || codePoint >= 0x2f800 && codePoint <= 0x2fa1f))
|
|
27
|
+
categories.push("compatibility_ideograph");
|
|
28
|
+
const flags = getLegacyFlags(codePoint);
|
|
29
|
+
if (flags & legacyFlags.vendorExtension)
|
|
30
|
+
categories.push("vendor_extension");
|
|
31
|
+
const cp932Extensions = [];
|
|
32
|
+
for (const [flag, area] of cp932Areas) {
|
|
33
|
+
if (flags & flag)
|
|
34
|
+
cp932Extensions.push(area);
|
|
35
|
+
}
|
|
36
|
+
return { character, codePoint, isUnicodeScalar: !isSurrogate(codePoint), categories, cp932Extensions };
|
|
37
|
+
}
|
|
38
|
+
export function classifyCharacter(character) {
|
|
39
|
+
const codePoint = character.codePointAt(0);
|
|
40
|
+
if (codePoint === undefined || character.length !== (codePoint > 0xffff ? 2 : 1)) {
|
|
41
|
+
throw new RangeError("Expected exactly one code point or lone UTF-16 surrogate");
|
|
42
|
+
}
|
|
43
|
+
return classify({ character, codePoint });
|
|
44
|
+
}
|
|
45
|
+
export function checkCharacters(value, options = {}) {
|
|
46
|
+
const { encoding = "unicode", allowedCharacters, reportCategories, rejectCategories } = options;
|
|
47
|
+
validateEncoding(encoding);
|
|
48
|
+
const allowed = typeof allowedCharacters === "string" ? new Set(allowedCharacters) : allowedCharacters;
|
|
49
|
+
const issues = [];
|
|
50
|
+
let encodable = true;
|
|
51
|
+
for (const position of iterateCharacters(value)) {
|
|
52
|
+
const result = measureCharacter(position.codePoint, encoding);
|
|
53
|
+
if (typeof result !== "number") {
|
|
54
|
+
issues.push(encodingIssue(position, encoding, result));
|
|
55
|
+
encodable = false;
|
|
56
|
+
if (result === "invalid_surrogate")
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const isAllowed = typeof allowed === "function" ? allowed({ ...position }) : allowed?.has(position.character);
|
|
60
|
+
if (isAllowed === false) {
|
|
61
|
+
issues.push({ ...position, encoding, reason: "disallowed_character", severity: "error" });
|
|
62
|
+
}
|
|
63
|
+
if (reportCategories?.length === 0 && !rejectCategories?.length)
|
|
64
|
+
continue;
|
|
65
|
+
const { categories, cp932Extensions } = classify(position);
|
|
66
|
+
for (const reason of categories) {
|
|
67
|
+
const rejected = rejectCategories?.includes(reason);
|
|
68
|
+
if (rejected || !reportCategories || reportCategories.includes(reason)) {
|
|
69
|
+
issues.push({ ...position, reason, encoding, cp932Extensions: [...cp932Extensions],
|
|
70
|
+
severity: rejected ? "error" : "warning" });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return { ok: !issues.some((issue) => issue.severity === "error"), encodable, encoding, issues };
|
|
75
|
+
}
|
package/dist/counts.d.ts
ADDED
package/dist/counts.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { segmentGraphemes } from "./characters.js";
|
|
2
|
+
export function getCharacterCounts(value) {
|
|
3
|
+
let codePointCount = 0;
|
|
4
|
+
for (const _ of value)
|
|
5
|
+
codePointCount++;
|
|
6
|
+
return { codePointCount, utf16CodeUnitCount: value.length };
|
|
7
|
+
}
|
|
8
|
+
export function countGraphemeClusters(value) {
|
|
9
|
+
let count = 0;
|
|
10
|
+
for (const _ of segmentGraphemes(value))
|
|
11
|
+
count++;
|
|
12
|
+
return count;
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type CharacterPosition } from "./characters.js";
|
|
2
|
+
export type ByteEncoding = "utf-8" | "shift_jis" | "cp932" | "windows-31j";
|
|
3
|
+
export type CharacterEncoding = ByteEncoding | "unicode" | "jis-x-0208";
|
|
4
|
+
export type EncodingFailureReason = "invalid_surrogate" | "unsupported_character" | "non_round_trip";
|
|
5
|
+
export interface EncodingIssue extends CharacterPosition {
|
|
6
|
+
reason: EncodingFailureReason;
|
|
7
|
+
encoding: CharacterEncoding;
|
|
8
|
+
severity: "error";
|
|
9
|
+
}
|
|
10
|
+
export declare function getLegacyFlags(codePoint: number): number;
|
|
11
|
+
export declare function validateEncoding(encoding: CharacterEncoding): void;
|
|
12
|
+
export declare function measureCharacter(codePoint: number, encoding: CharacterEncoding): number | EncodingFailureReason;
|
|
13
|
+
export declare function encodingIssue(position: CharacterPosition, encoding: CharacterEncoding, reason: EncodingFailureReason): EncodingIssue;
|
|
14
|
+
export declare function isEncodable(value: string, encoding: CharacterEncoding): boolean;
|
|
15
|
+
export declare function findUnsupportedChars(value: string, encoding: CharacterEncoding): EncodingIssue[];
|
package/dist/encoding.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { isSurrogate, iterateCharacters } from "./characters.js";
|
|
2
|
+
import { legacyFlags, packedLegacyRuns } from "./legacy-data.js";
|
|
3
|
+
let legacyRuns;
|
|
4
|
+
function unpackLegacyRuns() {
|
|
5
|
+
const runs = new Uint16Array(packedLegacyRuns.length);
|
|
6
|
+
let end = -1;
|
|
7
|
+
for (let index = 0; index < runs.length; index += 3) {
|
|
8
|
+
const start = end + 1 + packedLegacyRuns.charCodeAt(index) - 0x30;
|
|
9
|
+
end = start + packedLegacyRuns.charCodeAt(index + 1) - 0x30;
|
|
10
|
+
runs[index] = start;
|
|
11
|
+
runs[index + 1] = end;
|
|
12
|
+
runs[index + 2] = packedLegacyRuns.charCodeAt(index + 2) - 0x30;
|
|
13
|
+
}
|
|
14
|
+
return runs;
|
|
15
|
+
}
|
|
16
|
+
export function getLegacyFlags(codePoint) {
|
|
17
|
+
if (codePoint > 0xffff)
|
|
18
|
+
return 0;
|
|
19
|
+
const runs = legacyRuns ?? (legacyRuns = unpackLegacyRuns());
|
|
20
|
+
let low = 0;
|
|
21
|
+
let high = runs.length / 3 - 1;
|
|
22
|
+
while (low <= high) {
|
|
23
|
+
const middle = (low + high) >>> 1;
|
|
24
|
+
const index = middle * 3;
|
|
25
|
+
if (codePoint < runs[index]) {
|
|
26
|
+
high = middle - 1;
|
|
27
|
+
}
|
|
28
|
+
else if (codePoint > runs[index + 1]) {
|
|
29
|
+
low = middle + 1;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
return runs[index + 2];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return 0;
|
|
36
|
+
}
|
|
37
|
+
export function validateEncoding(encoding) {
|
|
38
|
+
switch (encoding) {
|
|
39
|
+
case "utf-8":
|
|
40
|
+
case "shift_jis":
|
|
41
|
+
case "cp932":
|
|
42
|
+
case "windows-31j":
|
|
43
|
+
case "unicode":
|
|
44
|
+
case "jis-x-0208":
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
throw new RangeError(`Unknown character encoding: ${encoding}`);
|
|
48
|
+
}
|
|
49
|
+
// Unicode and JIS X 0208 have membership checks only and return 0 for members.
|
|
50
|
+
export function measureCharacter(codePoint, encoding) {
|
|
51
|
+
if (isSurrogate(codePoint))
|
|
52
|
+
return "invalid_surrogate";
|
|
53
|
+
if (encoding === "unicode")
|
|
54
|
+
return 0;
|
|
55
|
+
if (encoding === "utf-8") {
|
|
56
|
+
if (codePoint <= 0x7f)
|
|
57
|
+
return 1;
|
|
58
|
+
if (codePoint <= 0x7ff)
|
|
59
|
+
return 2;
|
|
60
|
+
if (codePoint <= 0xffff)
|
|
61
|
+
return 3;
|
|
62
|
+
return 4;
|
|
63
|
+
}
|
|
64
|
+
const flags = getLegacyFlags(codePoint);
|
|
65
|
+
if (encoding === "jis-x-0208")
|
|
66
|
+
return flags & legacyFlags.jis0208 ? 0 : "unsupported_character";
|
|
67
|
+
if (encoding === "shift_jis") {
|
|
68
|
+
if (flags & legacyFlags.shiftJisSingle)
|
|
69
|
+
return 1;
|
|
70
|
+
return flags & legacyFlags.jis0208 ? 2 : "unsupported_character";
|
|
71
|
+
}
|
|
72
|
+
if (flags & legacyFlags.cp932Single)
|
|
73
|
+
return 1;
|
|
74
|
+
if (flags & legacyFlags.cp932Double)
|
|
75
|
+
return 2;
|
|
76
|
+
return flags & legacyFlags.cp932BestFit ? "non_round_trip" : "unsupported_character";
|
|
77
|
+
}
|
|
78
|
+
export function encodingIssue(position, encoding, reason) {
|
|
79
|
+
return { ...position, encoding, reason, severity: "error" };
|
|
80
|
+
}
|
|
81
|
+
export function isEncodable(value, encoding) {
|
|
82
|
+
validateEncoding(encoding);
|
|
83
|
+
for (const character of value) {
|
|
84
|
+
if (typeof measureCharacter(character.codePointAt(0), encoding) !== "number")
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
export function findUnsupportedChars(value, encoding) {
|
|
90
|
+
validateEncoding(encoding);
|
|
91
|
+
const issues = [];
|
|
92
|
+
for (const position of iterateCharacters(value)) {
|
|
93
|
+
const result = measureCharacter(position.codePoint, encoding);
|
|
94
|
+
if (typeof result !== "number")
|
|
95
|
+
issues.push(encodingIssue(position, encoding, result));
|
|
96
|
+
}
|
|
97
|
+
return issues;
|
|
98
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { checkCharacters, classifyCharacter } from "./check.js";
|
|
2
|
+
export type { AllowedCharacters, CharacterCategory, CharacterCategoryIssue, CharacterClassification, CharacterIssue, CheckCharactersOptions, CheckCharactersResult, Cp932Extension, DisallowedCharacterIssue, } from "./check.js";
|
|
3
|
+
export type { CharacterPosition } from "./characters.js";
|
|
4
|
+
export { countGraphemeClusters, getCharacterCounts } from "./counts.js";
|
|
5
|
+
export type { CharacterCounts } from "./counts.js";
|
|
6
|
+
export { findUnsupportedChars, isEncodable } from "./encoding.js";
|
|
7
|
+
export type { ByteEncoding, CharacterEncoding, EncodingFailureReason, EncodingIssue } from "./encoding.js";
|
|
8
|
+
export { CharacterEncodingError, getByteLength, truncateByBytes } from "./bytes.js";
|
|
9
|
+
export type { TruncateOptions } from "./bytes.js";
|
|
10
|
+
export { applyReplacements, suggestReplacements } from "./replacements.js";
|
|
11
|
+
export type { ReplacementCandidate, ReplacementKind, ReplacementOptions, ReplacementSelector, ReplacementSuggestion, } from "./replacements.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { checkCharacters, classifyCharacter } from "./check.js";
|
|
2
|
+
export { countGraphemeClusters, getCharacterCounts } from "./counts.js";
|
|
3
|
+
export { findUnsupportedChars, isEncodable } from "./encoding.js";
|
|
4
|
+
export { CharacterEncodingError, getByteLength, truncateByBytes } from "./bytes.js";
|
|
5
|
+
export { applyReplacements, suggestReplacements } from "./replacements.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const legacyFlags: {
|
|
2
|
+
readonly jis0208: 1;
|
|
3
|
+
readonly shiftJisSingle: 2;
|
|
4
|
+
readonly cp932Single: 4;
|
|
5
|
+
readonly cp932Double: 8;
|
|
6
|
+
readonly cp932BestFit: 16;
|
|
7
|
+
readonly vendorExtension: 32;
|
|
8
|
+
readonly necSpecial: 64;
|
|
9
|
+
readonly necSelectedIbm: 128;
|
|
10
|
+
readonly ibm: 256;
|
|
11
|
+
readonly userDefined: 512;
|
|
12
|
+
readonly microsoftSingle: 1024;
|
|
13
|
+
};
|
|
14
|
+
export declare const packedLegacyRuns: string;
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
// Generated by scripts/generate-mappings.mjs. See docs/mappings.md and LICENSE-Unicode.txt.
|
|
2
|
+
// Each run stores a gap from the previous run, length minus one, and flags, offset by 0x30.
|
|
3
|
+
export const legacyFlags = {
|
|
4
|
+
jis0208: 1,
|
|
5
|
+
shiftJisSingle: 2,
|
|
6
|
+
cp932Single: 4,
|
|
7
|
+
cp932Double: 8,
|
|
8
|
+
cp932BestFit: 16,
|
|
9
|
+
vendorExtension: 32,
|
|
10
|
+
necSpecial: 64,
|
|
11
|
+
necSelectedIbm: 128,
|
|
12
|
+
ibm: 256,
|
|
13
|
+
userDefined: 512,
|
|
14
|
+
microsoftSingle: 1024
|
|
15
|
+
};
|
|
16
|
+
export const packedLegacyRuns = "060050P600400600єP0@01A10B00@01902@00A02@01901@" +
|
|
17
|
+
"00900@00904@3G@0090N@00907@ˁ@91697@9169g09>o9109" +
|
|
18
|
+
"ᯮ09409001119219219319909119709202ô09B0Ƙ:0Ƙ909d9Ƙ" +
|
|
19
|
+
"69ǘF39n09109[091193192095000170y2190000y408119" +
|
|
20
|
+
"02y0091050900Ź709D0y=0900y419219F19219M0yI009" +
|
|
21
|
+
"ŽC¼39809219219219229209229209219219219219219209" +
|
|
22
|
+
"20980919@19819819309219O09E19i09109W09209109ী39" +
|
|
23
|
+
"1@96010010Q900@6392
9439Ţ0Ƙ0060409060" +
|
|
24
|
+
"30912130:040=1203050S3?1<220R080" +
|
|
25
|
+
"ᩢ1910934911911925940920940910ǘ109209319309119119" +
|
|
26
|
+
"209219109509129549329209>09109:09109109219149109" +
|
|
27
|
+
"219119219119149129109239109209209309529109119219" +
|
|
28
|
+
"12945932910ǘ12971910910931930900ǘ30ǘ00910ǘ519249" +
|
|
29
|
+
"809119A1930910910900ǘ00911950921954910910900ǘ009" +
|
|
30
|
+
"159:0951920911941920930920910910ǘ00910910910900ǘ" +
|
|
31
|
+
"10ǘ10910910ǘ00910921990912951980922940ǘ00920ǘ009" +
|
|
32
|
+
"11920921911910910910912981930911910910930900ǘ519" +
|
|
33
|
+
"20910910910911910910921930ǘ00910900ǘ039159809209" +
|
|
34
|
+
"60ǘ10ǘ00920ǘ02951941930910980960930ǘ109129109409" +
|
|
35
|
+
"20940970930920ǘ329A19439109609309209319209109109" +
|
|
36
|
+
"31910ǘ10930940910910951950ǘ009309109429109409809" +
|
|
37
|
+
"12910910940910980970940922922916900ǘ039109109109" +
|
|
38
|
+
"50910950910ǘ009269209339309309109219219119149129" +
|
|
39
|
+
"10930ǘ20910912914937950900ǘ529209129809429219419" +
|
|
40
|
+
"11910ǘ00921931912921910921912911920920920900ǘ109" +
|
|
41
|
+
"509619109119309109209259719209239109409109409209" +
|
|
42
|
+
"42931946970910930932930931910960900ǘ21920920ǘ249" +
|
|
43
|
+
"10ǘ10921930920910910ǘ009109109109109309409209129" +
|
|
44
|
+
"10ǘ139129119:1910922931900ǘ01921900ǘ009409119429" +
|
|
45
|
+
"11920921910900ǘ509409109109439329109159209339219" +
|
|
46
|
+
"10910910910950920943900ǘ029119209309209109>0ǘ209" +
|
|
47
|
+
"10910941941911931910910ǘ009209409619469509119109" +
|
|
48
|
+
"10910ǘ1091492;9229109609119399909109119509209139" +
|
|
49
|
+
"709119139109109309129309209=09809109519109129329" +
|
|
50
|
+
"20930910930ǘ01912910990ǘ50911920900ǘ119209219409" +
|
|
51
|
+
"329129109229>0981921911931930970920910ǘ409119719" +
|
|
52
|
+
"309109G19109109419409109329509209309219419509G19" +
|
|
53
|
+
"10910921910ǘ009129<29139759109109509=19109<09509" +
|
|
54
|
+
"109209319B09109319709209:09129209=09509119109109" +
|
|
55
|
+
"109909909109109:09809309129709309109509519209409" +
|
|
56
|
+
"409;09109209809509109509339409509209109319119209" +
|
|
57
|
+
"109209:09109119519209119219319109109109219209109" +
|
|
58
|
+
"30920962940920961920940910940920933970ǘ70920900ǘ" +
|
|
59
|
+
"009219D09209519109709<0912950910ǘ309209<09209209" +
|
|
60
|
+
"01ǘ209209329109509219209@09209119109309109219319" +
|
|
61
|
+
"909309309309209509429219409209219819519109239309" +
|
|
62
|
+
"309609109409109209309409409109=0930940910ǘ009809" +
|
|
63
|
+
"20920930ǘ009439209209309109209109409109109129209" +
|
|
64
|
+
"11941951914940914940961900ǘ319419149509209109159" +
|
|
65
|
+
"21941950950922943910ǘ01911910900ǘ10ǘ20910900ǘ109" +
|
|
66
|
+
"13910910941930940933950920950920920910910950900ǘ" +
|
|
67
|
+
"00920930950960900ǘ009209709209109419119419109819" +
|
|
68
|
+
"109119:09409309109109509709609109109219409309509" +
|
|
69
|
+
"519509319409209@09709309309109B09B09719P29219609" +
|
|
70
|
+
"119309519909109209209@19=09119909;09709109309109" +
|
|
71
|
+
"309709109209109:1921900ǘ019139109339209109419109" +
|
|
72
|
+
"109209109509209109129129109509169109249709109239" +
|
|
73
|
+
"11950900ǘ15910920930912930ǘ20912911915910900ǘ109" +
|
|
74
|
+
"10920911910910931911917912910910920930930ǘ109109" +
|
|
75
|
+
"109309409309699319109119149109109809119219609119" +
|
|
76
|
+
"109409209B09319209<0940ǘ11911940910922910ǘ019109" +
|
|
77
|
+
"609109A0961962920911940ǘ009319109909309209209279" +
|
|
78
|
+
"30920940ǘ109H0ǘ81910910910900ǘ809<0920900ǘ109309" +
|
|
79
|
+
"209;09109209319309<0940990910980901ǘ009119;09219" +
|
|
80
|
+
"20ǘ119209409119209109139209209249109309119319209" +
|
|
81
|
+
"419409409229109709509109119209229409209229109409" +
|
|
82
|
+
"109519109709139=49179109119209209409529209109309" +
|
|
83
|
+
"519309109739829429419209209319109149419209319119" +
|
|
84
|
+
"12912911910911944912915920930910ǘ329109309109109" +
|
|
85
|
+
"20ǘ00911930910920930ǘ209109109109209109219109219" +
|
|
86
|
+
"31930900ǘ149219109309109209269119129339329409119" +
|
|
87
|
+
"62921941920ǘ10921950910961983921900ǘ109309609419" +
|
|
88
|
+
"309209209109109>29109219209129219369309109809629" +
|
|
89
|
+
"20931910920910920931920ǘ119139259119409109909119" +
|
|
90
|
+
"00ǘ30900ǘ029409109119219319209219119749109319729" +
|
|
91
|
+
"90910910ǘ20910910910ǘ02910931971900ǘ019119129419" +
|
|
92
|
+
"10920911932910ǘ30941930900ǘ00951930930ǘ30920ǘ439" +
|
|
93
|
+
"209109219149409109229209109219109119209239149609" +
|
|
94
|
+
"30940920930911920910910ǘ019909209109119109309309" +
|
|
95
|
+
"309309409279209B09209;0910912910914972912912900ǘ" +
|
|
96
|
+
"009109319129109409309329129309209329529109119409" +
|
|
97
|
+
"109209209209109209409509209409209209129129419679" +
|
|
98
|
+
"21910970ǘ419409309309129409259119159229129219:39" +
|
|
99
|
+
"109109129619119429209409709509719209309:09229909" +
|
|
100
|
+
"219119409109409:29109209309319219409209419209119" +
|
|
101
|
+
"209309109209349109159509119509209109219109209519" +
|
|
102
|
+
"10930931950910950940950900ǘ009309;09609109309219" +
|
|
103
|
+
"409909109319609109309309309;0990970ǘ609109509609" +
|
|
104
|
+
"10910980940991910940920ǘ009519309109119109109609" +
|
|
105
|
+
"11941920910950900ǘ309109309109539219409209119109" +
|
|
106
|
+
"109309219109409B09319519529209459109219509209409" +
|
|
107
|
+
"00ǘ009109349319319209509309109119119919329209109" +
|
|
108
|
+
"119509109119209109219109329119609109219309139419" +
|
|
109
|
+
"20920940910910942924921930981940ǘ11921910ǘ009109" +
|
|
110
|
+
"11931900ǘ60910ǘ01930ǘ00911940900ǘ00910ǘ22940ǘ009" +
|
|
111
|
+
"20913940910930920940ǘ10ǘ32920910900ǘ03942920ǘ009" +
|
|
112
|
+
"10930960911922940920942900ǘ30920ǘ10930940920930ǘ" +
|
|
113
|
+
"10931920910900ǘ109209209109<09219119209509209609" +
|
|
114
|
+
"13912901ǘ04920941910910900ǘ009439309129629149209" +
|
|
115
|
+
"20912910920910910940920943910920920920917900ǘ309" +
|
|
116
|
+
"209149109109409119509109109119309409109209119229" +
|
|
117
|
+
"30920950931913910ǘ40ǘ009209109309339119309109219" +
|
|
118
|
+
"30910920910920911910912950921910ǘ029>09219609219" +
|
|
119
|
+
"62960910931921923900ǘ10910941911900ǘ019409219109" +
|
|
120
|
+
"309309<09119619109109109709109319209309109119109" +
|
|
121
|
+
"32940912910911921910970910910ǘ02910910ǘ209119119" +
|
|
122
|
+
"109429109309619209619519219209249209639429119109" +
|
|
123
|
+
"109509309109209309109:0982931912912950ǘ119129329" +
|
|
124
|
+
"12922921970930920921920ǘ219309609609219109609219" +
|
|
125
|
+
"10910930924910920941931930ǘ419209109409609109109" +
|
|
126
|
+
"10920920942952920910910921912952920910ǘ419129209" +
|
|
127
|
+
"60910ǘ019209<1950911930940ǘ60900ǘ40950ǘ019309819" +
|
|
128
|
+
"109609409309119609109109409409209529=09109619219" +
|
|
129
|
+
"20ǘ10ǘ309109?19819409709309609129109309:09439219" +
|
|
130
|
+
"409309109209109109219409109309139109219409319319" +
|
|
131
|
+
"109319219109229109719109509509519309149109229219" +
|
|
132
|
+
"41940911932910ǘ109209309;19209309D09609109119209" +
|
|
133
|
+
"309719?0921950900ǘ029;0910940910920910ǘ039109509" +
|
|
134
|
+
"10940ǘ00911960921922920ǘ109319209119209229519809" +
|
|
135
|
+
"20920910947910921931910960910910910900ǘ009109329" +
|
|
136
|
+
"109209109429109@0ǘ619509409109109219509329619119" +
|
|
137
|
+
"109209119209219C1910961910921910910900ǘ409229;09" +
|
|
138
|
+
"10ǘ00930910940910900ǘ209119?0ǘ209209209209309309" +
|
|
139
|
+
"42931920ǘ11920921940920920910910912910920900ǘ009" +
|
|
140
|
+
"10910900ǘ02900ǘ80914970910932910912913900ǘ109149" +
|
|
141
|
+
"80900ǘ00910ǘ10940960921970910920900ǘ209709309219" +
|
|
142
|
+
"209309729109909219509109319109209209409409209319" +
|
|
143
|
+
"20920910ǘ209119309119409129719=09209209109219519" +
|
|
144
|
+
"119309209509109129:09119719419509519109309>09309" +
|
|
145
|
+
"21920940910963930930910910932910910910ǘ509209509" +
|
|
146
|
+
"90911950960910910ǘ309639209=19209209329209619119" +
|
|
147
|
+
"10910910ǘ00930930920930ǘ10ǘ109109309109309209119" +
|
|
148
|
+
"12961900ǘ309309109;09=09409609:0970931970931970ǘ" +
|
|
149
|
+
"319309309609A0ǘ03930942900ǘ<09209309909309109A09" +
|
|
150
|
+
"70930960ǘ40950ǘ409419109409409?0950991ǘ109209109" +
|
|
151
|
+
"61920920ǘ509139109209109>09609309109409419309509" +
|
|
152
|
+
"80930940970940920ǘ109419409109109119109719429429" +
|
|
153
|
+
"60930911910ǘ009609609209:09<09109119209109219369" +
|
|
154
|
+
"529219509519109109109119409109809109409319129409" +
|
|
155
|
+
":0930990910940940920910ǘ00930920940ǘ329109709109" +
|
|
156
|
+
"109409109109429609219929219<09;1932910940ǘ009329" +
|
|
157
|
+
"219409119619419819709;0940910950910920910ǘ009119" +
|
|
158
|
+
"809209109109:09B0981970910ǘ20910950900ǘ00921930ǘ" +
|
|
159
|
+
"30ǘ70910920ǘ10940921920930ǘ20950940911900ǘ109H09" +
|
|
160
|
+
"20900ǘ21ǘ30ǘ349309409109C0933912910ǘ019419419209" +
|
|
161
|
+
"20970940950ǘ109B0900ǘ209409809<09<09409409709309" +
|
|
162
|
+
"11921910940912932980ǘ129629209109109209109109119" +
|
|
163
|
+
"30911910921920ǘ039319129709109249109109209449209" +
|
|
164
|
+
"10913912910910ǘ009219129609209319129219109209509" +
|
|
165
|
+
"209509109509529109219229319109109209209409119219" +
|
|
166
|
+
"109209319509609129509109119109709109109A39109209" +
|
|
167
|
+
"809309609609329309509309109309419439109309109309" +
|
|
168
|
+
"10914910910ǘ01912920920910920920921901ǘ10ǘ70ǘ709" +
|
|
169
|
+
"109309239409219209109109209409319319119109129109" +
|
|
170
|
+
"209309309109309209209209209229119>09229329209=19" +
|
|
171
|
+
"10910930950ǘ009B19509109119109209=09419;09209209" +
|
|
172
|
+
"<09109409619209209209209129109709509909229519109" +
|
|
173
|
+
"109109329309809509909509119:0900ǘ329:09109509409" +
|
|
174
|
+
"50980ǘ>0960ǘ61920920910950ǘ109409419429209109109" +
|
|
175
|
+
"109209809309119409509409109109209319319419209509" +
|
|
176
|
+
"<19309209409809309509609219609<0932930ǘ909109109" +
|
|
177
|
+
"119529609209129209239109209209409909209429219409" +
|
|
178
|
+
"22940ǘ60ǘ109819209309109209519249709109519209209" +
|
|
179
|
+
"609109119119109209309:09409709209119509239109219" +
|
|
180
|
+
"=09219409359119209209339609929509109409309109219" +
|
|
181
|
+
"209109109119309919139609919329509309409329119119" +
|
|
182
|
+
"10910910ǘ01910931911914911900ǘ20900ǘ109119509129" +
|
|
183
|
+
"409209109109109119309109619109209109419109309609" +
|
|
184
|
+
"119209;19119129139109109609709109409109119219409" +
|
|
185
|
+
";1930910910920911913911900ǘ009109809209309209309" +
|
|
186
|
+
"719209119109119209=09209329209309509219809609509" +
|
|
187
|
+
"339209709109109309219;19439209819119309109109619" +
|
|
188
|
+
"319609609109809229509109109209109209119209309119" +
|
|
189
|
+
"119119209119229509319109109209409309309309109309" +
|
|
190
|
+
"129109409709209109109109119209109109129319109209" +
|
|
191
|
+
"31915932981912911910931940924910ǘ21912950940900ǘ" +
|
|
192
|
+
"109229209109509229119209309;0950930953920900ǘ119" +
|
|
193
|
+
"77911910ǘ00911912970921930911920900ǘ109109129119" +
|
|
194
|
+
"209319209209209109609509219329609809219129209409" +
|
|
195
|
+
"20921920910912911920910920931910940ǘ129219219719" +
|
|
196
|
+
"11920920980912910921941900ǘ109129129109419É09109" +
|
|
197
|
+
"109:0910ǘ429119219209619649209109109209129819139" +
|
|
198
|
+
"10910910950950921920ǘ119319419209309119309309319" +
|
|
199
|
+
"309109509119:19409209109409209509119319139419309" +
|
|
200
|
+
"109209129209409609:09209409109109609309709309109" +
|
|
201
|
+
"109319119509619129119109329439109119609209109119" +
|
|
202
|
+
"109319209319119109119109509819109509109709229119" +
|
|
203
|
+
"209219909109209309319409259?19709509509109109509" +
|
|
204
|
+
"409709409209119129909519409209119209329419119409" +
|
|
205
|
+
"109409309109409119209219319609209109209109239109" +
|
|
206
|
+
"309119309309109429419209109119109209519529109219" +
|
|
207
|
+
"209139129109109329219119939109409149609609@29209" +
|
|
208
|
+
"109209109109109119219119329509<09109409609309109" +
|
|
209
|
+
"519429109109109419109109709;39209109119119109109" +
|
|
210
|
+
"12930950911942950ǘ049209409729309609409209309119" +
|
|
211
|
+
"12911960940931941910950990ǘ@0910910931920ǘ509109" +
|
|
212
|
+
"11930940920930932910950911950930970930930910ǘ209" +
|
|
213
|
+
"10910940920910930921980910933910910ǘ009309109519" +
|
|
214
|
+
"209339409<0910961910940930920931980910ǘ009409809" +
|
|
215
|
+
"309529209209149109309109119709109609409309409209" +
|
|
216
|
+
"209109;0940910ǘ319119209109209109229109219409219" +
|
|
217
|
+
"10ǘ?09109509709219509:09129119109409109409519709" +
|
|
218
|
+
"70921910943920940ǘ10911900ǘ00980942900ǘ109909609" +
|
|
219
|
+
"10930921910951920920910911970910914911900ǘ819609" +
|
|
220
|
+
"709309119409619619319<09129209309319219709219209" +
|
|
221
|
+
"709:09119>09=19109319409109119709309509709109>29" +
|
|
222
|
+
"609109=19429319509=09119109109119509409109219409" +
|
|
223
|
+
"409239819109209109119209129209319509109109809309" +
|
|
224
|
+
":09209309309909119109409109109109519209209109109" +
|
|
225
|
+
"309509109109609209:09A09209809309309619109209309" +
|
|
226
|
+
"119309409109=09>0920931910910920960910ǘ529109319" +
|
|
227
|
+
":29309909409209109409109109109519419309109109119" +
|
|
228
|
+
"229409209409109209109529119509209109409319109409" +
|
|
229
|
+
"309109609209119219109709149909419219219109109609" +
|
|
230
|
+
"92900ǘ21922930910920920910930911980ǘ019609419:09" +
|
|
231
|
+
"109209509119719809729309109309209109209109209619" +
|
|
232
|
+
"109109229119309309229109609419119109209219609209" +
|
|
233
|
+
"119A09709119509219<0930970911940910910910910910ǘ" +
|
|
234
|
+
"00922920910910930910940920930911910900ǘ229409409" +
|
|
235
|
+
"10972911950920910911920920913913950ǘ209509119109" +
|
|
236
|
+
"10921930910910920910930911913900ǘ009319209109609" +
|
|
237
|
+
"20910ǘ00920910920932910920930932910900ǘ029109119" +
|
|
238
|
+
"30911920910920ǘ019109309129109209409109109309119" +
|
|
239
|
+
"12910921940910921960950940920970920911930ǘ209109" +
|
|
240
|
+
"12920960941923910920950910ǘ009209609109109109119" +
|
|
241
|
+
"209219Ì09209409109409109109109109109409409619729" +
|
|
242
|
+
";29109509209319129509309419129499129129229159219" +
|
|
243
|
+
"10921920910962910910912910930920920ǘ30ǘ539619119" +
|
|
244
|
+
"11910911910ǘ019109}0911930910921911910ǘ009909309" +
|
|
245
|
+
"409>09909409:09609309309819209609319109109109109" +
|
|
246
|
+
"409119309309109609209829419<29:09509319<09109239" +
|
|
247
|
+
"109309409309519219=09109109509409219109219109309" +
|
|
248
|
+
"119409709829229<0961910913910ǘ209809309219709<09" +
|
|
249
|
+
"239409109319109539309129109609219409309419109219" +
|
|
250
|
+
"209129209229809409209139f19119309319459409229209" +
|
|
251
|
+
"209119809209209509709219229109119309239209219109" +
|
|
252
|
+
"119409149149119269309609219219119209109219209109" +
|
|
253
|
+
"12919911920910911910910910ǘ019329209239109119159" +
|
|
254
|
+
"209119409109A09209109109409109309209809809309<09" +
|
|
255
|
+
"20ǘ219109309409709109509409?0920ǘ309=0ǘ509209109" +
|
|
256
|
+
"F59309109109109919109319109519109119909409109109" +
|
|
257
|
+
"109209109409409509109519309419209109519439169409" +
|
|
258
|
+
"00ǘ00910ǘ02900ǘ00910910901ǘ01951ǘ61950920960ǘ30ǘ" +
|
|
259
|
+
"21910ǘ009219809:0920970920911ǘ10ǘ20900ǘ319219109" +
|
|
260
|
+
"20ǘ10900ǘ50910ǘ01920930910910900ǘ90951ǘ509109209" +
|
|
261
|
+
"10920ǘ809109119109129:0ǘ509909109E0900ǘ10900ǘ10ǘ" +
|
|
262
|
+
"10ǘ10ǘ60ǘ30920ǘ11920941940900ǘ00900ǘ00920ǘ20ǘ309" +
|
|
263
|
+
"81972921ǘ10900ǘ01910ǘ00910921911920920941980930ǘ" +
|
|
264
|
+
"20910960910900ǘ319309;0910910ǘ409609109=09709119" +
|
|
265
|
+
"20990ǘ20942910980990920ǘ10971942940900ǘ209219209" +
|
|
266
|
+
"?0ǘ:0930980921932960990950ǘ31910910960920900ǘ20ǘ" +
|
|
267
|
+
"829619209109109709509409109439109ĥ09809119309129" +
|
|
268
|
+
"30910900ǘ019109119609139119409409609119109409309" +
|
|
269
|
+
"209119629109309419209f09409609109319209809319109" +
|
|
270
|
+
"109629119:49249309109309119139109209719109119129" +
|
|
271
|
+
"41912911900ǘ20920931910940ǘ029109139119319239109" +
|
|
272
|
+
"139209319209119519409119409109319109109409309129" +
|
|
273
|
+
"10922910910920920920910950920920950910900ǘ41910ǘ" +
|
|
274
|
+
"11930900ǘ00910911930ǘ10ǘ10ǘ00920ǘ009209209109129" +
|
|
275
|
+
"109109119109109309209419109409229409109119709309" +
|
|
276
|
+
"309209209109209109519>09209109209709809@19319119" +
|
|
277
|
+
"409309129119109309249319109609209719609219229809" +
|
|
278
|
+
"44941910ǘ00920920960ǘ109309329119c09109409109409" +
|
|
279
|
+
"<19109D19209209609109129209109729409109319109309" +
|
|
280
|
+
"12930941911920920ǘ009309109>19309209309119329209" +
|
|
281
|
+
"109n3940ǘ609209329419709409229109729209209209109" +
|
|
282
|
+
"109209:19219509209309109309819219509>09209409609" +
|
|
283
|
+
"60910911910970900ǘ609109219309209119329l09409209" +
|
|
284
|
+
"709309309309:0910911930900ǘ20ǘ119219209319129109" +
|
|
285
|
+
"209209309:09A09109409219109139319119819449729109" +
|
|
286
|
+
"209309109D0920ǘ10900ǘ=09:0900ǘ129219719709119119" +
|
|
287
|
+
"20ǘ20940910ǘ409509219409119109109409539309729209" +
|
|
288
|
+
":0ǘ309109129119209139509509219739109629209729909" +
|
|
289
|
+
"409209509609>0910909109109119309219109<09239409" +
|
|
290
|
+
"309209509309309209109129>09219109209109109719709" +
|
|
291
|
+
"22911920960ǘ00920900ǘ109709<09109509:09909409109" +
|
|
292
|
+
"309209109309119519109109809309509<09609109209529" +
|
|
293
|
+
"209K0ǘ01920909219309109109609219429109109509109" +
|
|
294
|
+
"519219209:4911940974900ǘ009109319139109409209609" +
|
|
295
|
+
"409119109129919509409109:19:09>09209;19219209109" +
|
|
296
|
+
":49219209109509319E09709619209䂏އȸᇈ3ȴe0ǘâ0ǘaOǘԃ09" +
|
|
297
|
+
"00ǘ03900ǘ0490080]90080P90082n6p1800Ƹ00900ǘ009";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { CharacterEncoding, EncodingIssue } from "./encoding.js";
|
|
2
|
+
export type ReplacementCandidate = {
|
|
3
|
+
replacement: string;
|
|
4
|
+
kind: "legacy_mapping_variant";
|
|
5
|
+
basis: "shared_legacy_code";
|
|
6
|
+
legacyCode: number;
|
|
7
|
+
} | {
|
|
8
|
+
replacement: string;
|
|
9
|
+
kind: "unicode_compatibility";
|
|
10
|
+
basis: "unicode_nfkc" | "width_variant";
|
|
11
|
+
};
|
|
12
|
+
export type ReplacementKind = ReplacementCandidate["kind"];
|
|
13
|
+
export interface ReplacementOptions {
|
|
14
|
+
encoding: CharacterEncoding;
|
|
15
|
+
}
|
|
16
|
+
export interface ReplacementSuggestion extends EncodingIssue {
|
|
17
|
+
candidates: ReplacementCandidate[];
|
|
18
|
+
}
|
|
19
|
+
export declare function suggestReplacements(value: string, { encoding }: ReplacementOptions): ReplacementSuggestion[];
|
|
20
|
+
export type ReplacementSelector = (suggestion: Readonly<Omit<ReplacementSuggestion, "candidates">> & {
|
|
21
|
+
readonly candidates: readonly Readonly<ReplacementCandidate>[];
|
|
22
|
+
}) => string | undefined;
|
|
23
|
+
export declare function applyReplacements(value: string, options: ReplacementOptions, approve: ReplacementSelector): string;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { findUnsupportedChars, isEncodable } from "./encoding.js";
|
|
2
|
+
// Same byte positions in the archived Shift_JIS table and Microsoft CP932.
|
|
3
|
+
const mappingVariants = [
|
|
4
|
+
[0x815f, "\\", "\"],
|
|
5
|
+
[0x8160, "〜", "~"],
|
|
6
|
+
[0x8161, "‖", "∥"],
|
|
7
|
+
[0x817c, "−", "-"],
|
|
8
|
+
[0x8191, "¢", "¢"],
|
|
9
|
+
[0x8192, "£", "£"],
|
|
10
|
+
[0x81ca, "¬", "¬"],
|
|
11
|
+
];
|
|
12
|
+
export function suggestReplacements(value, { encoding }) {
|
|
13
|
+
const suggestions = [];
|
|
14
|
+
for (const issue of findUnsupportedChars(value, encoding)) {
|
|
15
|
+
const { character, codePoint } = issue;
|
|
16
|
+
const candidates = [];
|
|
17
|
+
for (const [legacyCode, strict, windows] of mappingVariants) {
|
|
18
|
+
const replacement = character === strict ? windows : character === windows ? strict : undefined;
|
|
19
|
+
if (replacement && isEncodable(replacement, encoding)) {
|
|
20
|
+
candidates.push({ replacement, legacyCode, kind: "legacy_mapping_variant", basis: "shared_legacy_code" });
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (character === "¥" && isEncodable("¥", encoding)) {
|
|
24
|
+
candidates.push({ replacement: "¥", kind: "unicode_compatibility", basis: "width_variant" });
|
|
25
|
+
}
|
|
26
|
+
if ((codePoint >= 0x2460 && codePoint <= 0x2473) || (codePoint >= 0x2160 && codePoint <= 0x217f) ||
|
|
27
|
+
character === "¥") {
|
|
28
|
+
const replacement = character.normalize("NFKC");
|
|
29
|
+
if (replacement !== character && isEncodable(replacement, encoding)) {
|
|
30
|
+
candidates.push({ replacement, kind: "unicode_compatibility", basis: "unicode_nfkc" });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (candidates.length > 0)
|
|
34
|
+
suggestions.push({ ...issue, candidates });
|
|
35
|
+
}
|
|
36
|
+
return suggestions;
|
|
37
|
+
}
|
|
38
|
+
export function applyReplacements(value, options, approve) {
|
|
39
|
+
if (typeof approve !== "function")
|
|
40
|
+
throw new TypeError("A replacement approval callback is required");
|
|
41
|
+
const parts = [];
|
|
42
|
+
let from = 0;
|
|
43
|
+
for (const suggestion of suggestReplacements(value, options)) {
|
|
44
|
+
const { utf16Index, character, candidates } = suggestion;
|
|
45
|
+
const replacement = approve({ ...suggestion, candidates: candidates.map((candidate) => ({ ...candidate })) });
|
|
46
|
+
if (replacement === undefined)
|
|
47
|
+
continue;
|
|
48
|
+
if (!candidates.some((candidate) => candidate.replacement === replacement)) {
|
|
49
|
+
throw new RangeError("The approved replacement must be a candidate for this occurrence");
|
|
50
|
+
}
|
|
51
|
+
parts.push(value.slice(from, utf16Index), replacement);
|
|
52
|
+
from = utf16Index + character.length;
|
|
53
|
+
}
|
|
54
|
+
parts.push(value.slice(from));
|
|
55
|
+
return parts.join("");
|
|
56
|
+
}
|
package/docs/api.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# APIリファレンス
|
|
2
|
+
|
|
3
|
+
[README](../README.md) · [English README](../README.en.md) · [判定プロファイル](mappings.md)
|
|
4
|
+
|
|
5
|
+
## 型と位置
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
type ByteEncoding = "utf-8" | "shift_jis" | "cp932" | "windows-31j"
|
|
9
|
+
type CharacterEncoding = ByteEncoding | "unicode" | "jis-x-0208"
|
|
10
|
+
type EncodingFailureReason = "invalid_surrogate" | "unsupported_character" | "non_round_trip"
|
|
11
|
+
|
|
12
|
+
interface CharacterPosition {
|
|
13
|
+
character: string
|
|
14
|
+
codePoint: number
|
|
15
|
+
utf16Index: number
|
|
16
|
+
codePointIndex: number
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
どちらの位置も0始まりです。`utf16Index` はJavaScriptの `slice` で使える位置で、補助平面の文字で2進みます。`codePointIndex` は `for...of` と同じ単位で1進みます。孤立サロゲートは位置報告上1単位を占め、`codePoint` にはそのコードユニット値が入ります。
|
|
21
|
+
|
|
22
|
+
## 文字コードと文字集合
|
|
23
|
+
|
|
24
|
+
| API | 戻り値と動作 |
|
|
25
|
+
| --- | --- |
|
|
26
|
+
| `isEncodable(value, encoding)` | 入力全体が指定プロファイルで往復可能か、または指定文字集合に属するかを返す。 |
|
|
27
|
+
| `findUnsupportedChars(value, encoding)` | 失敗した出現箇所の `EncodingIssue[]` を入力順に返す。同じ文字の複数出現も個別に返す。 |
|
|
28
|
+
| `checkCharacters(value, options?)` | `CheckCharactersResult` を返す。既定の `encoding` は `unicode`。 |
|
|
29
|
+
| `classifyCharacter(character)` | `CharacterClassification` を返す。1コードポイントまたは孤立サロゲート1個を受け付け、空文字列や複数コードポイントには `RangeError` が発生する。 |
|
|
30
|
+
|
|
31
|
+
`EncodingIssue` は `CharacterPosition` に `reason`、`encoding`、`severity: "error"` を加えた型です。`invalid_surrogate` は孤立サロゲート、`unsupported_character` は対応がない文字、`non_round_trip` はMicrosoftの表で変換先から元のコードポイントに戻らない文字を示します。未知の文字コード識別子には `RangeError` が発生します。空文字列はすべてのプロファイルで有効です。
|
|
32
|
+
|
|
33
|
+
`checkCharacters` の `encodable` は文字コード判定を表します。`ok` は `issues` に `severity: "error"` が一つもない場合に真となります。`issues` は出現順で、同じ位置では文字コードの問題、カスタム文字集合の問題、カテゴリの順です。
|
|
34
|
+
|
|
35
|
+
| オプション | 動作 |
|
|
36
|
+
| --- | --- |
|
|
37
|
+
| `allowedCharacters` | 許可文字を並べた文字列、`ReadonlySet<string>`、または `CharacterPosition` を受け取る述語。コードポイントごとに照合し、不一致は `disallowed_character` になる。空集合を指定すると空入力だけが許可される。孤立サロゲートは `invalid_surrogate` となり、述語は呼ばれない。 |
|
|
38
|
+
| `reportCategories` | 警告として報告するカテゴリ。省略時は全カテゴリで、空配列で警告を抑制できる。 |
|
|
39
|
+
| `rejectCategories` | 指定したカテゴリをエラーとして報告する。`reportCategories` の指定にかかわらずエラーが優先される。 |
|
|
40
|
+
|
|
41
|
+
### カテゴリと拡張領域
|
|
42
|
+
|
|
43
|
+
| カテゴリ | 判定条件 |
|
|
44
|
+
| --- | --- |
|
|
45
|
+
| `control` | Unicode一般カテゴリ `Cc`。改行、タブ、DEL、C1を含む。 |
|
|
46
|
+
| `invisible` | `Cf`、`Default_Ignorable_Code_Point`、U+2028、U+2029。 |
|
|
47
|
+
| `variation_selector` | Unicode二値プロパティ `Variation_Selector`。補助平面とモンゴル文字のセレクタを含む。 |
|
|
48
|
+
| `combining_mark` | Unicode一般カテゴリ `M`。結合濁点や異体字セレクタが該当し、単独で判定される。 |
|
|
49
|
+
| `halfwidth_kana` | U+FF61〜U+FF9F。半角カナ、濁点・半濁点と半角約物を含む。 |
|
|
50
|
+
| `private_use` | Unicode一般カテゴリ `Co`。CP932のユーザー定義領域はこの分類で検出できる。 |
|
|
51
|
+
| `compatibility_ideograph` | UnicodeのCJK互換漢字またはCJK互換漢字補助ブロック内の割り当て済み文字。 |
|
|
52
|
+
| `vendor_extension` | CP932の優先Unicode→バイト割り当てがNEC特殊、NEC選定IBM、IBM拡張、またはMicrosoft単バイト拡張に属し、往復可能な文字。 |
|
|
53
|
+
|
|
54
|
+
`classifyCharacter` の `categories` は複数該当します。`cp932Extensions` は、CP932で往復可能な文字について、重複割り当ても含めてデコード表で確認できる拡張領域を列挙します。値は `nec_special`、`nec_selected_ibm`、`ibm`、`user_defined`、`microsoft_single_byte` です。分類の警告・エラーにも `cp932Extensions` が入ります。Unicodeプロパティ判定は実行環境のUnicodeデータを使います。
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
import { checkCharacters } from "ja-char-check"
|
|
58
|
+
|
|
59
|
+
checkCharacters("受付1", { allowedCharacters: "受付0123456789" }).ok // true
|
|
60
|
+
checkCharacters("A\t", { encoding: "cp932", reportCategories: [], rejectCategories: ["control"] }).ok // false
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## 文字数・バイト数
|
|
64
|
+
|
|
65
|
+
| API | 戻り値と動作 |
|
|
66
|
+
| --- | --- |
|
|
67
|
+
| `getCharacterCounts(value)` | `{ codePointCount, utf16CodeUnitCount }`。孤立サロゲートをJavaScriptの文字列イテレーターと同じく1単位として数える。 |
|
|
68
|
+
| `countGraphemeClusters(value)` | `Intl.Segmenter` による書記素クラスタ数。結合濁点やZWJで連結した絵文字は1クラスタになり得る。 |
|
|
69
|
+
| `getByteLength(value, encoding)` | `ByteEncoding` でのバイト数。BOMや終端の追加分は含めない。 |
|
|
70
|
+
| `truncateByBytes(value, maxBytes, encoding, options?)` | 上限内に収まる最長の接頭辞。`maxBytes` は0以上の安全な整数。`boundary: "grapheme"` が既定で、`"code-point"` を指定するとコードポイント境界で切り詰める。 |
|
|
71
|
+
|
|
72
|
+
バイト系APIは入力全体を検証します。切り捨てる範囲の文字も含め、最初の変換不可位置は `CharacterEncodingError.issue` で確認できます。`unicode` と `jis-x-0208` は所属判定用のため、バイト系APIへの指定は `RangeError` になります。書記素クラスタの分割には実行環境の `Intl.Segmenter` が必要です。上限内で入力全体を返せる場合や、空の接頭辞を返す場合、切り詰めに書記素分割は発生しません。
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
import { CharacterEncodingError, truncateByBytes } from "ja-char-check"
|
|
76
|
+
|
|
77
|
+
truncateByBytes("Aか\u3099", 4, "utf-8") // "A"
|
|
78
|
+
truncateByBytes("Aか\u3099", 4, "utf-8", { boundary: "code-point" }) // "Aか"
|
|
79
|
+
|
|
80
|
+
try {
|
|
81
|
+
truncateByBytes("A𠮷", 1, "cp932") // 上限外の「𠮷」で例外
|
|
82
|
+
} catch (error) {
|
|
83
|
+
if (error instanceof CharacterEncodingError) console.log(error.issue.utf16Index) // 1
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## 置換支援
|
|
88
|
+
|
|
89
|
+
`suggestReplacements(value, { encoding })` は候補のある変換不可箇所の `ReplacementSuggestion[]` を返します。各要素は `EncodingIssue` と `candidates` を持ちます。各候補の `replacement` は対象プロファイルで表現できます。
|
|
90
|
+
|
|
91
|
+
| `kind` | `basis` | 根拠 |
|
|
92
|
+
| --- | --- | --- |
|
|
93
|
+
| `legacy_mapping_variant` | `shared_legacy_code` | Shift_JISとCP932で同じバイト位置に割り当てられた異なる文字。`legacyCode` がその位置を示す。 |
|
|
94
|
+
| `unicode_compatibility` | `unicode_nfkc` | NFKCによる互換分解。例では `①` から `1`、`Ⅻ` から `XII`。 |
|
|
95
|
+
| `unicode_compatibility` | `width_variant` | 円記号の幅違い。`¥`(U+00A5)に対して `¥`(U+FFE5)を提案。 |
|
|
96
|
+
|
|
97
|
+
`applyReplacements(value, { encoding }, approve)` は各出現箇所の候補を `approve` に渡します。コールバックはその出現箇所で承認した候補の文字列を返します。`undefined` は元の文字をそのまま使います。候補外の値には `RangeError`、コールバック省略には `TypeError` が発生します。位置は元入力上の値です。候補を持たない文字や未承認の文字は保持されるため、変換先への出力可否は置換後に `isEncodable` などで確認できます。
|
package/docs/mappings.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# 判定プロファイルとマッピングデータ
|
|
2
|
+
|
|
3
|
+
## 判定の定義
|
|
4
|
+
|
|
5
|
+
`isEncodable` は、プロファイルの文字集合への所属、またはそのプロファイルでコードポイントをバイト列に変換して元のコードポイントへ戻せることを検査します。バイト系APIはこの同じ定義で測定します。照合は入力に含まれる各コードポイント単位で行い、正規化や文字列の合成は行いません。
|
|
6
|
+
|
|
7
|
+
| 識別子 | 判定内容 | バイト数 |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| `unicode` | U+0000〜U+10FFFFのうちサロゲートを除くUnicodeスカラー値。未割り当て、非文字、私用領域もスカラー値に含まれる。 | — |
|
|
10
|
+
| `utf-8` | Unicodeスカラー値をRFC 3629のUTF-8で往復できること。 | 1〜4 |
|
|
11
|
+
| `jis-x-0208` | Unicodeのアーカイブ表 `JIS0208.TXT` v2.0が示すJIS X 0208:1990の6,879文字。 | — |
|
|
12
|
+
| `shift_jis` | `SHIFTJIS.TXT` v2.0のJIS X 0201・0208対応と、同じ値の1バイトとして保持するC0制御文字とDEL。7,070コードポイント。 | 1〜2 |
|
|
13
|
+
| `cp932` / `windows-31j` | Microsoft `bestfit932.txt` のUnicode→バイト (`WCTABLE`) とバイト→Unicode (`MBTABLE`、`DBCSTABLE`) が一致する9,402コードポイント。`CP932.TXT` v2.01との共通バイト割り当ても照合。 | 1〜2 |
|
|
14
|
+
|
|
15
|
+
JIS X 0208は文字集合です。`jis-x-0208` はJIS X 0201のローマ字・半角カナを含まず、JIS X 0208に収録される全角ラテン文字や、採用した表で区点1-32に対応する U+005C は所属します。JISの区点やShift_JISのバイト列を返すAPIは設けていません。`shift_jis` は上記のアーカイブ表に固定したプロファイルです。特にU+005Cが2バイトになるため、ASCII互換のShift_JIS実装や、Webブラウザで `shift_jis` と `windows-31j` が同じデコーダーを指すWHATWG Encodingの定義とは結果が異なります。
|
|
16
|
+
|
|
17
|
+
| バイト位置 | `shift_jis` | `cp932` |
|
|
18
|
+
| --- | --- | --- |
|
|
19
|
+
| `0x5C` | ¥ U+00A5 | `\` U+005C |
|
|
20
|
+
| `0x7E` | ‾ U+203E | ~ U+007E |
|
|
21
|
+
| `0x815F` | `\` U+005C | \ U+FF3C |
|
|
22
|
+
| `0x8160` | 〜 U+301C | ~ U+FF5E |
|
|
23
|
+
| `0x8161` | ‖ U+2016 | ∥ U+2225 |
|
|
24
|
+
| `0x817C` | − U+2212 | - U+FF0D |
|
|
25
|
+
| `0x8191` | ¢ U+00A2 | ¢ U+FFE0 |
|
|
26
|
+
| `0x8192` | £ U+00A3 | £ U+FFE1 |
|
|
27
|
+
| `0x81CA` | ¬ U+00AC | ¬ U+FFE2 |
|
|
28
|
+
|
|
29
|
+
Microsoft表に片方向の割り当てがある84文字は `non_round_trip` です。たとえば U+00A5 は `0x5C` に写せますが、CP932でデコードすると U+005C になります。U+301C は同じ表の `WCTABLE` に割り当てがなく、`unsupported_character` です。一部のエンコーダーは U+301C を `0x8160` に写すなど独自の片方向割り当てを持つため、連携先ではこのプロファイルと実際のエンコーダーを照合してください。未割り当てバイトへの既定文字フォールバック、ベストフィット、合成、UTF-8 BOMの自動付加はバイト数に含めません。
|
|
30
|
+
|
|
31
|
+
CP932のバイト領域は、NEC特殊 `0x87xx`、NEC選定IBM `0xEDxx`〜`0xEExx`、IBM拡張 `0xFAxx`〜`0xFCxx`、ユーザー定義 `0xF0xx`〜`0xF9xx` と単バイト `0xA0`、`0xFD`〜`0xFF`、Microsoft単バイト `0x80` として、表に存在する割り当てを分類します。たとえば `髙` には `0xEEE0` と `0xFBFC` があり、どちらも分類に反映されます。`∵` の優先割り当ては標準領域の `0x81E6` なので、拡張領域にも割り当てがあるものの `vendor_extension` の警告は出ません。ユーザー定義領域のU+E000〜U+E757、U+F8F0〜U+F8F3は往復でき、`private_use` として検出できます。私用領域のコードポイントから字形やシステム間の対応を推定することはできません。
|
|
32
|
+
|
|
33
|
+
[IANA Character Sets](https://www.iana.org/assignments/character-sets/) · [WHATWG Encoding Standard](https://encoding.spec.whatwg.org/#shift_jis) · [RFC 3629](https://www.rfc-editor.org/rfc/rfc3629) · [Microsoft WindowsBestFitの仕様](https://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WindowsBestFit/readme.txt) · [WideCharToMultiByte](https://learn.microsoft.com/en-us/windows/win32/api/stringapiset/nf-stringapiset-widechartomultibyte) · [UAX #29](https://www.unicode.org/reports/tr29/)
|
|
34
|
+
|
|
35
|
+
## 出典・ライセンス
|
|
36
|
+
|
|
37
|
+
| データ | 用途 |
|
|
38
|
+
| --- | --- |
|
|
39
|
+
| [Unicode `JIS0208.TXT` v2.0](https://www.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/JIS/JIS0208.TXT) | JIS X 0208:1990のUnicode対応。区点とShift_JIS 2バイトの対応も記載。 |
|
|
40
|
+
| [Unicode `SHIFTJIS.TXT` v2.0](https://www.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/JIS/SHIFTJIS.TXT) | 厳密プロファイルの本体。2バイト部分が `JIS0208.TXT` と同一であることを確認。 |
|
|
41
|
+
| [Microsoft `CP932.TXT` v2.01](https://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP932.TXT) | CP932の共通割り当てとベンダー拡張を照合。 |
|
|
42
|
+
| [Microsoft `bestfit932.txt`](https://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WindowsBestFit/bestfit932.txt) | CP932の厳密な往復、片方向マッピング、ユーザー定義領域。 |
|
|
43
|
+
|
|
44
|
+
Unicode掲載の両JIS表には `© 2015 Unicode, Inc.` とUnicode利用規約への参照があります。Microsoftの両データファイルとWindowsBestFitの形式説明には別途の配布条件が記載されていません。Unicode利用規約が `/Public/` 以下のデータに適用するUnicode License v3を同梱し、ライブラリコードのMITライセンスと併記しています。npmのSPDX表記は `MIT AND Unicode-3.0` です。 [Unicode Terms of Use](https://www.unicode.org/copyright.html) · [Unicode License v3](../LICENSE-Unicode.txt)
|
|
45
|
+
|
|
46
|
+
## 再生成と検証
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
npm run generate:mappings -- --download
|
|
50
|
+
npm run generate:mappings -- --check
|
|
51
|
+
npm test
|
|
52
|
+
npm run build:demo
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
`--download` は生成時だけネットワークを使用し、`.mapping-sources/` に4ファイルを置きます。同じファイルが手元にある場合は、そのディレクトリに配置して `npm run generate:mappings` を実行できます。各入力のSHA-256は生成スクリプトで固定しています。一致しないファイルではビルド用コードを更新しません。変換結果は同じ分類フラグを持つ連続範囲にまとめ、範囲間の差分をUTF-16コードユニットで表した `src/legacy-data.ts` に出力します。実行時は最初のマッピング参照時に範囲を展開し、二分探索します。通常のビルド、npm配布物、ブラウザデモは生成済みデータを使います。
|
|
56
|
+
|
|
57
|
+
テストは公式表のバイト割り当てを根拠に、レパートリーの総数、7つの異なるマッピング、拡張の重複割り当て、ユーザー定義領域の境界を確認します。UTF-8の境界と、孤立サロゲート、結合濁点、異体字セレクタ、ZWJ絵文字の切り詰めも検証します。Unicodeのカテゴリと分割は実行環境のUnicodeデータに従います。 [UAX #44](https://www.unicode.org/reports/tr44/) · [UAX #15](https://www.unicode.org/reports/tr15/)
|
|
58
|
+
|
|
59
|
+
## シリーズと周辺ライブラリの調査
|
|
60
|
+
|
|
61
|
+
ローカルのREADME、公開型・実装、テスト、ビルド設定、デモ、ライセンス、配布手順を調査しました。各HEADが公開GitHubの `main` と一致することを確認しました。
|
|
62
|
+
|
|
63
|
+
| リポジトリ | 調査時のHEADと取り入れた点 |
|
|
64
|
+
| --- | --- |
|
|
65
|
+
| [normalize-ja-input](https://github.com/fusaihanabi/normalize-ja-input) | `45415cc`。ESM、純粋な関数、加工と明細のAPI、MIT、`docs/` デモ、Windows・UbuntuでのGitHub Actions。`npm pack` した実物を一時利用側で検証。 |
|
|
66
|
+
| [ja-form-validators](https://github.com/fusaihanabi/ja-form-validators) | `0960f87`。真偽値と理由付き結果、文字位置、Vitest、生成データの出典とライセンス併記、`docs/` デモ。READMEに配布チェックを記載。現行ツリーに `.github/workflows` はなかった。 |
|
|
67
|
+
| [tiny-ja-date](https://github.com/fusaihanabi/tiny-ja-date) | `63f314d`。TypeScriptを `src/`、Vitestを `test/`、静的デモを `docs/` に配置。MIT、NodeNextでのtarballのオフライン利用検証。現行ツリーに `.github/workflows` はなかった。 |
|
|
68
|
+
|
|
69
|
+
`iconv-lite` は多くの文字コードを変換し、`encoding-japanese` は変換と検出を提供します。後者の `SJIS` はCP932拡張を含みます。本ライブラリではフォーム入力時の診断、往復判定、位置付きエラー、バイト制限を公開APIにしています。EUC-JPはJIS X 0212やシフト指定の扱い、ISO-2022-JPは状態遷移を含むバイト計算、JIS X 0213は追加マッピングと複数コードポイントの対応が必要です。これらは初回の対応範囲から外しました。 [iconv-lite](https://github.com/pillarjs/iconv-lite) · [encoding-japanese](https://github.com/polygonplanet/encoding.js) · [WHATWG Encoding Standard](https://encoding.spec.whatwg.org/)
|
package/package.json
CHANGED
|
@@ -1,6 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ja-char-check",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Tiny TypeScript utilities for Japanese character checks and legacy encoding byte limits.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"import": "./dist/index.js"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"main": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"sideEffects": false,
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md",
|
|
18
|
+
"README.en.md",
|
|
19
|
+
"CHANGELOG.md",
|
|
20
|
+
"LICENSE",
|
|
21
|
+
"LICENSE-Unicode.txt",
|
|
22
|
+
"docs/api.md",
|
|
23
|
+
"docs/mappings.md"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsc -p tsconfig.build.json",
|
|
27
|
+
"build:demo": "npm run build && node scripts/build-demo.mjs",
|
|
28
|
+
"check:demo": "npm run build && node scripts/build-demo.mjs --check",
|
|
29
|
+
"typecheck": "tsc --noEmit",
|
|
30
|
+
"test": "vitest run",
|
|
31
|
+
"check:package": "npm run build && node scripts/check-package.mjs",
|
|
32
|
+
"generate:mappings": "node scripts/generate-mappings.mjs",
|
|
33
|
+
"prepublishOnly": "npm run typecheck && npm test && npm run check:package"
|
|
34
|
+
},
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "git+https://github.com/fusaihanabi/ja-char-check.git"
|
|
38
|
+
},
|
|
39
|
+
"keywords": ["japanese", "shift-jis", "cp932", "jis-x-0208", "utf-8", "validation", "typescript"],
|
|
40
|
+
"license": "MIT AND Unicode-3.0",
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"typescript": "^5.9.3",
|
|
43
|
+
"vitest": "^4.1.6"
|
|
44
|
+
}
|
|
45
|
+
}
|