@mavogel/awscdk-rootmail 0.1.5 → 0.1.6
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/.jsii +3 -3
- package/lib/rootmail.js +1 -1
- package/lib/ses-receive.js +1 -1
- package/node_modules/@aws-sdk/client-cloudwatch-logs/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/client-cloudwatch-logs/package.json +1 -1
- package/node_modules/@aws-sdk/client-route-53/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/client-route-53/package.json +1 -1
- package/node_modules/@aws-sdk/client-s3/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/client-s3/package.json +2 -2
- package/node_modules/@aws-sdk/client-ses/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/client-ses/package.json +1 -1
- package/node_modules/@aws-sdk/client-ssm/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/client-ssm/package.json +1 -1
- package/node_modules/@zone-eu/mailsplit/package.json +3 -3
- package/node_modules/encoding-japanese/LICENSE +25 -1
- package/node_modules/encoding-japanese/README.md +86 -51
- package/node_modules/encoding-japanese/encoding.js +107 -78
- package/node_modules/encoding-japanese/encoding.min.js +2 -2
- package/node_modules/encoding-japanese/index.d.ts +102 -0
- package/node_modules/encoding-japanese/package.json +26 -17
- package/node_modules/encoding-japanese/src/encoding-convert.js +67 -58
- package/node_modules/encoding-japanese/src/encoding-table.js +1 -0
- package/node_modules/encoding-japanese/src/index.js +1 -1
- package/node_modules/encoding-japanese/src/kana-case-table.js +1 -1
- package/node_modules/encoding-japanese/src/utf8-to-jis-alias-table.js +14 -0
- package/node_modules/encoding-japanese/src/utf8-to-jis-table.js +6 -5
- package/node_modules/encoding-japanese/src/utf8-to-jisx0212-table.js +7 -5
- package/node_modules/libmime/CHANGELOG.md +7 -0
- package/node_modules/libmime/package.json +2 -2
- package/node_modules/mailparser/.release-please-manifest.json +1 -1
- package/node_modules/mailparser/CHANGELOG.md +14 -0
- package/node_modules/mailparser/package.json +5 -5
- package/node_modules/nodemailer/CHANGELOG.md +9 -0
- package/node_modules/nodemailer/dist/cjs/dkim/message-parser.js +12 -5
- package/node_modules/nodemailer/dist/cjs/mail-composer/index.js +3 -1
- package/node_modules/nodemailer/dist/cjs/mailer/mail-message.js +2 -1
- package/node_modules/nodemailer/dist/cjs/package-info.d.ts +1 -1
- package/node_modules/nodemailer/dist/cjs/package-info.js +1 -1
- package/node_modules/nodemailer/dist/cjs/smtp-connection/index.d.ts +3 -0
- package/node_modules/nodemailer/dist/cjs/smtp-connection/index.js +62 -18
- package/node_modules/nodemailer/dist/esm/dkim/message-parser.js +12 -5
- package/node_modules/nodemailer/dist/esm/mail-composer/index.js +3 -1
- package/node_modules/nodemailer/dist/esm/mailer/mail-message.js +2 -1
- package/node_modules/nodemailer/dist/esm/package-info.d.ts +1 -1
- package/node_modules/nodemailer/dist/esm/package-info.js +1 -1
- package/node_modules/nodemailer/dist/esm/smtp-connection/index.d.ts +3 -0
- package/node_modules/nodemailer/dist/esm/smtp-connection/index.js +62 -18
- package/node_modules/nodemailer/package.json +1 -1
- package/package.json +1 -1
package/.jsii
CHANGED
|
@@ -9167,7 +9167,7 @@
|
|
|
9167
9167
|
"stability": "experimental"
|
|
9168
9168
|
},
|
|
9169
9169
|
"homepage": "https://github.com/mavogel/awscdk-rootmail",
|
|
9170
|
-
"jsiiVersion": "5.9.
|
|
9170
|
+
"jsiiVersion": "5.9.54 (build 042bc62)",
|
|
9171
9171
|
"keywords": [
|
|
9172
9172
|
"aws",
|
|
9173
9173
|
"cdk",
|
|
@@ -9620,6 +9620,6 @@
|
|
|
9620
9620
|
"symbolId": "src/ses-receive:SESReceiveProps"
|
|
9621
9621
|
}
|
|
9622
9622
|
},
|
|
9623
|
-
"version": "0.1.
|
|
9624
|
-
"fingerprint": "
|
|
9623
|
+
"version": "0.1.6",
|
|
9624
|
+
"fingerprint": "3vVye3sjmqQXLPlsOG9y6W2aEx8K0ELBsFnPdjKJaxM="
|
|
9625
9625
|
}
|
package/lib/rootmail.js
CHANGED
|
@@ -11,7 +11,7 @@ const ses_receive_1 = require("./ses-receive");
|
|
|
11
11
|
* Rootmail construct
|
|
12
12
|
*/
|
|
13
13
|
class Rootmail extends constructs_1.Construct {
|
|
14
|
-
static [JSII_RTTI_SYMBOL_1] = { fqn: "@mavogel/awscdk-rootmail.Rootmail", version: "0.1.
|
|
14
|
+
static [JSII_RTTI_SYMBOL_1] = { fqn: "@mavogel/awscdk-rootmail.Rootmail", version: "0.1.6" };
|
|
15
15
|
/**
|
|
16
16
|
* The name parameter in SSM to store the domain name server.
|
|
17
17
|
*/
|
package/lib/ses-receive.js
CHANGED
|
@@ -11,7 +11,7 @@ const ses_receipt_ruleset_activation_1 = require("./ses-receipt-ruleset-activati
|
|
|
11
11
|
* SES Receive construct
|
|
12
12
|
*/
|
|
13
13
|
class SESReceive extends constructs_1.Construct {
|
|
14
|
-
static [JSII_RTTI_SYMBOL_1] = { fqn: "@mavogel/awscdk-rootmail.SESReceive", version: "0.1.
|
|
14
|
+
static [JSII_RTTI_SYMBOL_1] = { fqn: "@mavogel/awscdk-rootmail.SESReceive", version: "0.1.6" };
|
|
15
15
|
constructor(scope, id, props) {
|
|
16
16
|
super(scope, id);
|
|
17
17
|
const filteredEmailSubjects = props.filteredEmailSubjects || [];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/client-cloudwatch-logs",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1136.0",
|
|
4
4
|
"description": "AWS SDK for JavaScript Cloudwatch Logs Client for Node.js, Browser and React Native",
|
|
5
5
|
"homepage": "https://github.com/aws/aws-sdk-js-v3/tree/main/clients/client-cloudwatch-logs",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/client-route-53",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1136.0",
|
|
4
4
|
"description": "AWS SDK for JavaScript Route 53 Client for Node.js, Browser and React Native",
|
|
5
5
|
"homepage": "https://github.com/aws/aws-sdk-js-v3/tree/main/clients/client-route-53",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -4757,7 +4757,7 @@ var WriteGetObjectResponse$ = [9, n0, _WGOR,
|
|
|
4757
4757
|
class CreateSessionCommand extends command(_ep4, _mw0, "CreateSession", CreateSession$) {
|
|
4758
4758
|
}
|
|
4759
4759
|
|
|
4760
|
-
var version = "3.
|
|
4760
|
+
var version = "3.1135.0";
|
|
4761
4761
|
var packageInfo = {
|
|
4762
4762
|
version: version};
|
|
4763
4763
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/client-s3",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1136.0",
|
|
4
4
|
"description": "AWS SDK for JavaScript S3 Client for Node.js, Browser and React Native",
|
|
5
5
|
"homepage": "https://github.com/aws/aws-sdk-js-v3/tree/main/clients/client-s3",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"tslib": "^2.6.2"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@aws-sdk/signature-v4-crt": "3.
|
|
70
|
+
"@aws-sdk/signature-v4-crt": "3.1136.0",
|
|
71
71
|
"@smithy/snapshot-testing": "^2.3.2",
|
|
72
72
|
"@tsconfig/node20": "20.1.8",
|
|
73
73
|
"@types/node": "^20.14.8",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/client-ses",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1136.0",
|
|
4
4
|
"description": "AWS SDK for JavaScript Ses Client for Node.js, Browser and React Native",
|
|
5
5
|
"homepage": "https://github.com/aws/aws-sdk-js-v3/tree/main/clients/client-ses",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/client-ssm",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1136.0",
|
|
4
4
|
"description": "AWS SDK for JavaScript Ssm Client for Node.js, Browser and React Native",
|
|
5
5
|
"homepage": "https://github.com/aws/aws-sdk-js-v3/tree/main/clients/client-ssm",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zone-eu/mailsplit",
|
|
3
|
-
"version": "5.4.
|
|
3
|
+
"version": "5.4.17",
|
|
4
4
|
"description": "Split email messages into an object stream",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"license": "(MIT OR EUPL-1.1+)",
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"libbase64": "1.3.0",
|
|
19
|
-
"libmime": "5.4.
|
|
19
|
+
"libmime": "5.4.4",
|
|
20
20
|
"libqp": "2.1.1"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@types/grunt": "0.4.32",
|
|
26
26
|
"@types/libmime": "5.3.0",
|
|
27
27
|
"@types/libqp": "1.1.3",
|
|
28
|
-
"@types/node": "26.
|
|
28
|
+
"@types/node": "26.5.1",
|
|
29
29
|
"eslint": "8.29.0",
|
|
30
30
|
"eslint-config-nodemailer": "1.2.0",
|
|
31
31
|
"eslint-config-prettier": "9.1.0",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2012 polygonplanet
|
|
3
|
+
Copyright (c) 2012-present polygonplanet
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -19,3 +19,27 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
-----
|
|
24
|
+
|
|
25
|
+
Third-Party Licenses and Credits
|
|
26
|
+
|
|
27
|
+
TypeScript declarations and type tests are based on the type definitions for
|
|
28
|
+
encoding-japanese from DefinitelyTyped, licensed under the MIT License.
|
|
29
|
+
|
|
30
|
+
Upstream package: @types/encoding-japanese 2.2.1
|
|
31
|
+
|
|
32
|
+
The LICENSE distributed with @types/encoding-japanese states:
|
|
33
|
+
|
|
34
|
+
Copyright (c) Microsoft Corporation.
|
|
35
|
+
|
|
36
|
+
The LICENSE in the DefinitelyTyped repository states:
|
|
37
|
+
|
|
38
|
+
Copyrights are respective of each contributor listed at the beginning of
|
|
39
|
+
each definition file.
|
|
40
|
+
|
|
41
|
+
The contributors credited in the upstream package are:
|
|
42
|
+
rhysd (https://github.com/rhysd)
|
|
43
|
+
Piotr Błażejewicz (https://github.com/peterblazejewicz)
|
|
44
|
+
|
|
45
|
+
The MIT License terms stated above apply equally to these files.
|
|
@@ -3,44 +3,48 @@ encoding.js
|
|
|
3
3
|
|
|
4
4
|
[](https://www.npmjs.com/package/encoding-japanese)
|
|
5
5
|
[](https://github.com/polygonplanet/encoding.js/actions)
|
|
6
|
-
[](https://github.com/polygonplanet/encoding.js/blob/master/LICENSE)
|
|
7
7
|
|
|
8
|
-
Convert and detect character
|
|
8
|
+
Convert and detect character encodings in JavaScript.
|
|
9
9
|
|
|
10
10
|
[**README (日本語)**](README_ja.md)
|
|
11
11
|
|
|
12
12
|
## Table of contents
|
|
13
13
|
|
|
14
14
|
- [Features](#features)
|
|
15
|
-
* [How to
|
|
15
|
+
* [How to Handle Encoded Data as Strings?](#how-to-handle-encoded-data-as-strings)
|
|
16
16
|
- [Installation](#installation)
|
|
17
17
|
* [npm](#npm)
|
|
18
18
|
+ [TypeScript](#typescript)
|
|
19
19
|
* [Browser (standalone)](#browser-standalone)
|
|
20
20
|
* [CDN](#cdn)
|
|
21
21
|
- [Supported encodings](#supported-encodings)
|
|
22
|
+
* [About `SJIS`](#about-sjis)
|
|
22
23
|
* [About `UNICODE`](#about-unicode)
|
|
23
24
|
- [Example usage](#example-usage)
|
|
24
25
|
- [Demo](#demo)
|
|
26
|
+
* [Playground](#playground)
|
|
27
|
+
* [Sample file encoding conversion demo](#sample-file-encoding-conversion-demo)
|
|
28
|
+
* [User-selected file encoding conversion and detection demo](#user-selected-file-encoding-conversion-and-detection-demo)
|
|
25
29
|
- [API](#api)
|
|
26
|
-
* [detect : Detects character encoding](#encodingdetect-data-encodings)
|
|
27
|
-
* [convert : Converts character encoding](#encodingconvert-data-to-from)
|
|
28
|
-
+ [
|
|
30
|
+
* [`detect` : Detects character encoding](#encodingdetect-data-encodings)
|
|
31
|
+
* [`convert` : Converts character encoding](#encodingconvert-data-to-from)
|
|
32
|
+
+ [Specifying conversion options with an object](#specifying-conversion-options-with-an-object)
|
|
29
33
|
+ [Specify the return type by the `type` option](#specify-the-return-type-by-the-type-option)
|
|
30
34
|
+ [Specify handling for unrepresentable characters](#specify-handling-for-unrepresentable-characters)
|
|
31
35
|
+ [Replacing characters with HTML entities when they cannot be represented](#replacing-characters-with-html-entities-when-they-cannot-be-represented)
|
|
32
36
|
+ [Ignoring characters when they cannot be represented](#ignoring-characters-when-they-cannot-be-represented)
|
|
33
37
|
+ [Throwing an Error when they cannot be represented](#throwing-an-error-when-they-cannot-be-represented)
|
|
34
38
|
+ [Specify BOM in UTF-16](#specify-bom-in-utf-16)
|
|
35
|
-
* [urlEncode : Encodes to percent-encoded string](#encodingurlencode-data)
|
|
36
|
-
* [urlDecode : Decodes from percent-encoded string](#encodingurldecode-string)
|
|
37
|
-
* [base64Encode : Encodes to Base64 formatted string](#encodingbase64encode-data)
|
|
38
|
-
* [base64Decode : Decodes from Base64 formatted string](#encodingbase64decode-string)
|
|
39
|
-
* [codeToString : Converts character code array to string](#encodingcodetostring-code)
|
|
40
|
-
* [stringToCode : Converts string to character code array](#encodingstringtocode-string)
|
|
39
|
+
* [`urlEncode` : Encodes to percent-encoded string](#encodingurlencode-data)
|
|
40
|
+
* [`urlDecode` : Decodes from percent-encoded string](#encodingurldecode-string)
|
|
41
|
+
* [`base64Encode` : Encodes to Base64 formatted string](#encodingbase64encode-data)
|
|
42
|
+
* [`base64Decode` : Decodes from Base64 formatted string](#encodingbase64decode-string)
|
|
43
|
+
* [`codeToString` : Converts character code array to string](#encodingcodetostring-code)
|
|
44
|
+
* [`stringToCode` : Converts string to character code array](#encodingstringtocode-string)
|
|
41
45
|
* [Japanese Zenkaku/Hankaku conversion](#japanese-zenkakuhankaku-conversion)
|
|
42
46
|
- [Other examples](#other-examples)
|
|
43
|
-
* [Example using the `
|
|
47
|
+
* [Example using the `Fetch API` and Typed Arrays (Uint8Array)](#example-using-the-fetch-api-and-typed-arrays-uint8array)
|
|
44
48
|
* [Convert encoding for file using the File APIs](#convert-encoding-for-file-using-the-file-apis)
|
|
45
49
|
- [Contributing](#contributing)
|
|
46
50
|
- [License](#license)
|
|
@@ -52,22 +56,22 @@ supporting both Japanese character encodings (`Shift_JIS`, `EUC-JP`, `ISO-2022-J
|
|
|
52
56
|
|
|
53
57
|
Since JavaScript string values are internally encoded as UTF-16 code units
|
|
54
58
|
([ref: 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)),
|
|
55
|
-
|
|
56
|
-
enabling
|
|
59
|
+
data in other encodings cannot be handled directly as JavaScript strings.
|
|
60
|
+
encoding.js works around this limitation by representing encoded data as arrays of numeric code values instead of strings, enabling conversion between different character encodings.
|
|
61
|
+
For example, `[130, 160]` represents "あ" in Shift_JIS.
|
|
57
62
|
|
|
58
|
-
|
|
63
|
+
These character code arrays can also be passed as typed arrays (such as `Uint8Array`) or as Node.js `Buffer` objects.
|
|
59
64
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
### How to Use Character Encoding in Strings?
|
|
65
|
+
### How to Handle Encoded Data as Strings?
|
|
63
66
|
|
|
64
67
|
Numeric arrays of character codes can be converted to strings using methods such as [`Encoding.codeToString`](#encodingcodetostring-code).
|
|
65
68
|
However, due to the JavaScript specifications mentioned above, some character encodings may not be handled properly when converted directly to strings.
|
|
66
69
|
|
|
67
|
-
If you
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
If you need a string representation, [`Encoding.urlEncode`](#encodingurlencode-data) and
|
|
71
|
+
[`Encoding.urlDecode`](#encodingurldecode-string) can convert numeric arrays to and from
|
|
72
|
+
percent-encoded strings such as `'%82%A0'`.
|
|
73
|
+
Similarly, [`Encoding.base64Encode`](#encodingbase64encode-data) and
|
|
74
|
+
[`Encoding.base64Decode`](#encodingbase64decode-string) can convert numeric arrays to and from Base64 strings.
|
|
71
75
|
|
|
72
76
|
## Installation
|
|
73
77
|
|
|
@@ -121,7 +125,7 @@ When the script is loaded, the object `Encoding` is defined in the global scope
|
|
|
121
125
|
You can use encoding.js (package name: `encoding-japanese`) directly from a CDN via a script tag:
|
|
122
126
|
|
|
123
127
|
```html
|
|
124
|
-
<script src="https://unpkg.com/encoding-japanese@2.
|
|
128
|
+
<script src="https://unpkg.com/encoding-japanese@2.4.0/encoding.min.js"></script>
|
|
125
129
|
```
|
|
126
130
|
|
|
127
131
|
In this example we use [unpkg](https://unpkg.com/encoding-japanese/), but you can use any CDN that provides npm packages,
|
|
@@ -135,7 +139,7 @@ for example [cdnjs](https://cdnjs.com/libraries/encoding-japanese) or [jsDelivr]
|
|
|
135
139
|
|BINARY |✓ | |(Binary string. Code point range: `0-255`)|
|
|
136
140
|
|EUCJP |✓ |✓ |EUC-JP|
|
|
137
141
|
|JIS |✓ |✓ |ISO-2022-JP|
|
|
138
|
-
|SJIS |✓ |✓ |Shift_JIS|
|
|
142
|
+
|SJIS |✓ |✓ |Shift_JIS, Windows-31J (*See [About `SJIS`](#about-sjis) below)|
|
|
139
143
|
|UTF8 |✓ |✓ |UTF-8|
|
|
140
144
|
|UTF16 |✓ |✓ |UTF-16|
|
|
141
145
|
|UTF16BE |✓ |✓ |UTF-16BE (big-endian)|
|
|
@@ -143,18 +147,40 @@ for example [cdnjs](https://cdnjs.com/libraries/encoding-japanese) or [jsDelivr]
|
|
|
143
147
|
|UTF32 |✓ | |UTF-32|
|
|
144
148
|
|UNICODE |✓ |✓ |(JavaScript string. *See [About `UNICODE`](#about-unicode) below) |
|
|
145
149
|
|
|
150
|
+
### About `SJIS`
|
|
151
|
+
|
|
152
|
+
Strictly speaking, Shift_JIS and CP932 (also known as Windows-31J, MS932, SJIS-win, and other names) are different character encodings.
|
|
153
|
+
Following common usage, encoding.js defines encodings in the Shift_JIS family as `SJIS`.
|
|
154
|
+
|
|
155
|
+
`SJIS` covers CP932, an extension of Shift_JIS.
|
|
156
|
+
In addition to JIS X 0201 and JIS X 0208, it supports the following CP932 extension areas:
|
|
157
|
+
|
|
158
|
+
|Area |Code range |[`detect()`](#encodingdetect-data-encodings)|[`convert()`](#encodingconvert-data-to-from)|
|
|
159
|
+
|:-----------------------------------|:------------------|:----:|:----:|
|
|
160
|
+
|NEC special characters |`0x8740` - `0x879C`|✓ |✓ |
|
|
161
|
+
|NEC-selected IBM extended characters|`0xED40` - `0xEEFC`|✓ |✓ |
|
|
162
|
+
|User-defined area (外字 / Gaiji) |`0xF040` - `0xF9FC`|✓ | |
|
|
163
|
+
|IBM extended characters |`0xFA40` - `0xFC4B`|✓ |✓ |
|
|
164
|
+
|
|
165
|
+
The user-defined area is detected as `SJIS`, but it cannot be converted because its character assignments are not defined by any standard.
|
|
166
|
+
During conversion, characters in this area are replaced with `?` (U+003F).
|
|
167
|
+
|
|
146
168
|
### About `UNICODE`
|
|
147
169
|
|
|
148
|
-
In encoding.js, `UNICODE`
|
|
170
|
+
In encoding.js, `UNICODE` represents JavaScript strings (e.g., `"hello"` or `"こんにちは"`)
|
|
171
|
+
and is defined as the internal character representation used by JavaScript.
|
|
149
172
|
|
|
150
173
|
As mentioned in the [Features](#features) section, JavaScript strings are internally encoded using UTF-16 code units.
|
|
151
|
-
This means
|
|
152
|
-
Therefore, when converting to a
|
|
174
|
+
This means other character encodings cannot be directly handled without conversion.
|
|
175
|
+
Therefore, specify `UNICODE` when converting data to a form that can be properly represented as a JavaScript string.
|
|
153
176
|
|
|
154
|
-
(Note: Even if
|
|
177
|
+
(Note: Even if your HTML file is UTF-8 encoded, you should specify `UNICODE` instead of `UTF8` when handling data as JavaScript strings.)
|
|
155
178
|
|
|
156
|
-
When using [`Encoding.convert`](#encodingconvert-data-to-from),
|
|
157
|
-
|
|
179
|
+
When using [`Encoding.convert`](#encodingconvert-data-to-from),
|
|
180
|
+
if you specify a character encoding other than `UNICODE` (such as `UTF8` or `SJIS`),
|
|
181
|
+
the values in the returned character code array will range from `0` to `255` (byte array).
|
|
182
|
+
However, if you specify `UNICODE`, the values will range from `0` to `65535`,
|
|
183
|
+
which corresponds to the range of values returned by `String.prototype.charCodeAt()` (UTF-16 code units).
|
|
158
184
|
|
|
159
185
|
## Example usage
|
|
160
186
|
|
|
@@ -212,9 +238,18 @@ console.log(Encoding.codeToString(unicodeArray));
|
|
|
212
238
|
|
|
213
239
|
## Demo
|
|
214
240
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
241
|
+
### Playground
|
|
242
|
+
|
|
243
|
+
Try character encoding conversion and detection directly in your browser.
|
|
244
|
+
[Open the Playground](https://polygonplanet.github.io/encoding.js/tests/playground.html)
|
|
245
|
+
|
|
246
|
+
### Sample file encoding conversion demo
|
|
247
|
+
|
|
248
|
+
[Try converting sample files encoded in Shift_JIS, EUC-JP, and other encodings](https://polygonplanet.github.io/encoding.js/tests/encoding-test.html)
|
|
249
|
+
|
|
250
|
+
### User-selected file encoding conversion and detection demo
|
|
251
|
+
|
|
252
|
+
[Try converting and detecting the character encoding of a selected file](https://polygonplanet.github.io/encoding.js/tests/detect-file-encoding.html)
|
|
218
253
|
|
|
219
254
|
----
|
|
220
255
|
|
|
@@ -259,7 +294,7 @@ console.log(`Encoding is ${detectedEncoding}`); // 'Encoding is SJIS'
|
|
|
259
294
|
```
|
|
260
295
|
|
|
261
296
|
Example of using the `encodings` argument to specify the character encoding to be detected.
|
|
262
|
-
This returns
|
|
297
|
+
This returns the detected encoding name if the specified encoding matches, or `false` otherwise:
|
|
263
298
|
|
|
264
299
|
```javascript
|
|
265
300
|
const sjisArray = [130, 168, 130, 205, 130, 230]; // 'おはよ' array in SJIS
|
|
@@ -291,7 +326,7 @@ Converts the character encoding of the given data.
|
|
|
291
326
|
|
|
292
327
|
#### Parameters
|
|
293
328
|
|
|
294
|
-
* **data** *(Array\<number\>|TypedArray|Buffer|string)* : The code array or string to
|
|
329
|
+
* **data** *(Array\<number\>|TypedArray|Buffer|string)* : The code array or string to be converted.
|
|
295
330
|
* **to** *(string|Object)* : The character encoding name of the conversion destination as a string, or conversion options as an object.
|
|
296
331
|
* **\[from\]** *(string|Array\<string\>)* : (Optional) The character encoding name of the conversion source as a string,
|
|
297
332
|
or an array of encoding names. Detects automatically if this argument is omitted or `AUTO` is specified.
|
|
@@ -312,7 +347,7 @@ const sjisArray = Encoding.convert(utf8Array, 'SJIS', 'UTF8');
|
|
|
312
347
|
console.log(sjisArray); // [130, 160] ('あ' in SJIS)
|
|
313
348
|
```
|
|
314
349
|
|
|
315
|
-
|
|
350
|
+
Typed arrays, such as `Uint8Array`, and Node.js `Buffer` objects can be passed in the same way:
|
|
316
351
|
|
|
317
352
|
```javascript
|
|
318
353
|
const utf8Array = new Uint8Array([227, 129, 130]);
|
|
@@ -325,14 +360,14 @@ Converts character encoding by auto-detecting the encoding name of the source:
|
|
|
325
360
|
// The character encoding is automatically detected when the argument `from` is omitted
|
|
326
361
|
const utf8Array = [227, 129, 130];
|
|
327
362
|
let sjisArray = Encoding.convert(utf8Array, 'SJIS');
|
|
328
|
-
//
|
|
363
|
+
// You can also explicitly specify 'AUTO' to enable auto-detection
|
|
329
364
|
sjisArray = Encoding.convert(utf8Array, 'SJIS', 'AUTO');
|
|
330
365
|
```
|
|
331
366
|
|
|
332
|
-
####
|
|
367
|
+
#### Specifying conversion options with an object
|
|
333
368
|
|
|
334
|
-
|
|
335
|
-
|
|
369
|
+
For readability, the second argument `to` can be passed as an options object.
|
|
370
|
+
Options such as `type`, `fallback`, and `bom` must be specified this way.
|
|
336
371
|
|
|
337
372
|
```javascript
|
|
338
373
|
const utf8Array = [227, 129, 130];
|
|
@@ -345,7 +380,7 @@ const sjisArray = Encoding.convert(utf8Array, {
|
|
|
345
380
|
#### Specify the return type by the `type` option
|
|
346
381
|
|
|
347
382
|
`convert` returns an array by default, but you can change the return type by specifying the `type` option.
|
|
348
|
-
|
|
383
|
+
If `data` is a string and `type` is omitted, `type: 'string'` is assumed and the result is returned as a string.
|
|
349
384
|
|
|
350
385
|
```javascript
|
|
351
386
|
const sjisArray = [130, 168, 130, 205, 130, 230]; // 'おはよ' array in SJIS
|
|
@@ -360,8 +395,8 @@ console.log(unicodeString); // 'おはよ'
|
|
|
360
395
|
The following `type` options are supported.
|
|
361
396
|
|
|
362
397
|
* **string** : Return as a string.
|
|
363
|
-
* **arraybuffer** : Return
|
|
364
|
-
* **array** :
|
|
398
|
+
* **arraybuffer** : Return a `Uint16Array` (the option name is retained for historical reasons).
|
|
399
|
+
* **array** : Return as an Array. (*default*)
|
|
365
400
|
|
|
366
401
|
`type: 'string'` can be used as a shorthand for converting a code array to a string,
|
|
367
402
|
as performed by [`Encoding.codeToString`](#encodingcodetostring-code).
|
|
@@ -471,7 +506,7 @@ const utf16Array = Encoding.convert(utf8Array, {
|
|
|
471
506
|
});
|
|
472
507
|
```
|
|
473
508
|
|
|
474
|
-
|
|
509
|
+
The default byte order for `UTF16` is big-endian.
|
|
475
510
|
If you want to convert as little-endian, specify the `{ bom: 'LE' }` option.
|
|
476
511
|
|
|
477
512
|
```javascript
|
|
@@ -582,7 +617,7 @@ Decodes a Base64 encoded string to a numeric character code array.
|
|
|
582
617
|
|
|
583
618
|
#### Return value
|
|
584
619
|
|
|
585
|
-
*(Array\<number\>)* : Returns
|
|
620
|
+
*(Array\<number\>)* : Returns the decoded numeric character code array.
|
|
586
621
|
|
|
587
622
|
#### Examples
|
|
588
623
|
|
|
@@ -601,7 +636,7 @@ console.log(decodedArray); // [130, 177, 130, 241, 130, 201, 130, 191, 130, 205]
|
|
|
601
636
|
|
|
602
637
|
### Encoding.codeToString (code)
|
|
603
638
|
|
|
604
|
-
Converts a numeric character code array to string.
|
|
639
|
+
Converts a numeric character code array to a string.
|
|
605
640
|
|
|
606
641
|
#### Parameters
|
|
607
642
|
|
|
@@ -652,8 +687,8 @@ console.log(unicodeArray); // [12362, 12399, 12424]
|
|
|
652
687
|
|
|
653
688
|
### Japanese Zenkaku/Hankaku conversion
|
|
654
689
|
|
|
655
|
-
The following methods convert Japanese full-width (zenkaku) and half-width (hankaku) characters
|
|
656
|
-
|
|
690
|
+
The following methods convert Japanese full-width (zenkaku) and half-width (hankaku) characters.
|
|
691
|
+
They accept either `UNICODE` strings or numeric arrays of `UNICODE` code units.
|
|
657
692
|
|
|
658
693
|
Returns a converted string if the argument `data` is a string.
|
|
659
694
|
Returns a numeric character code array if the argument `data` is a code array.
|
|
@@ -664,8 +699,8 @@ Returns a numeric character code array if the argument `data` is a code array.
|
|
|
664
699
|
- **Encoding.toKatakanaCase (data)** : Converts full-width hiragana to full-width katakana.
|
|
665
700
|
- **Encoding.toHankanaCase (data)** : Converts full-width katakana to half-width katakana.
|
|
666
701
|
- **Encoding.toZenkanaCase (data)** : Converts half-width katakana to full-width katakana.
|
|
667
|
-
- **Encoding.toHankakuSpace (data)** : Converts the
|
|
668
|
-
- **Encoding.toZenkakuSpace (data)** : Converts
|
|
702
|
+
- **Encoding.toHankakuSpace (data)** : Converts the ideographic space (U+3000) to an ASCII space (U+0020).
|
|
703
|
+
- **Encoding.toZenkakuSpace (data)** : Converts an ASCII space (U+0020) to the ideographic space (U+3000).
|
|
669
704
|
|
|
670
705
|
#### Parameters
|
|
671
706
|
|