@mavogel/awscdk-rootmail 0.0.219 → 0.0.221

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.
Files changed (99) hide show
  1. package/.jsii +4 -4
  2. package/lib/rootmail.js +1 -1
  3. package/lib/ses-receive.js +1 -1
  4. package/node_modules/cdk-nag/.jsii +2 -2
  5. package/node_modules/cdk-nag/lib/ignore-suppression-conditions.js +5 -5
  6. package/node_modules/cdk-nag/lib/nag-logger.js +2 -2
  7. package/node_modules/cdk-nag/lib/nag-pack.js +1 -1
  8. package/node_modules/cdk-nag/lib/nag-rules.js +1 -1
  9. package/node_modules/cdk-nag/lib/nag-suppressions.js +1 -1
  10. package/node_modules/cdk-nag/lib/packs/aws-solutions.js +1 -1
  11. package/node_modules/cdk-nag/lib/packs/hipaa-security.js +1 -1
  12. package/node_modules/cdk-nag/lib/packs/nist-800-53-r4.js +1 -1
  13. package/node_modules/cdk-nag/lib/packs/nist-800-53-r5.js +1 -1
  14. package/node_modules/cdk-nag/lib/packs/pci-dss-321.js +1 -1
  15. package/node_modules/cdk-nag/package.json +1 -1
  16. package/node_modules/encoding-japanese/README.md +65 -13
  17. package/node_modules/encoding-japanese/encoding.js +7 -2
  18. package/node_modules/encoding-japanese/encoding.min.js +2 -2
  19. package/node_modules/encoding-japanese/package.json +2 -2
  20. package/node_modules/encoding-japanese/src/encoding-convert.js +5 -0
  21. package/node_modules/libbase64/.prettierrc.js +4 -1
  22. package/node_modules/libbase64/lib/libbase64.js +2 -1
  23. package/node_modules/libbase64/package.json +9 -8
  24. package/node_modules/libmime/CHANGELOG.md +7 -0
  25. package/node_modules/libmime/package.json +5 -5
  26. package/node_modules/libqp/CHANGELOG.md +15 -0
  27. package/node_modules/libqp/lib/libqp.js +13 -21
  28. package/node_modules/libqp/package.json +7 -6
  29. package/node_modules/libqp/test/libqp-test.js +161 -0
  30. package/node_modules/mailparser/CHANGELOG.md +7 -0
  31. package/node_modules/mailparser/package.json +8 -8
  32. package/node_modules/mailsplit/LICENSE.MIT +6 -1
  33. package/node_modules/mailsplit/README.md +2 -0
  34. package/node_modules/mailsplit/lib/headers.js +5 -1
  35. package/node_modules/mailsplit/package.json +10 -9
  36. package/node_modules/nodemailer/.ncurc.js +4 -1
  37. package/node_modules/nodemailer/CHANGELOG.md +25 -0
  38. package/node_modules/nodemailer/lib/addressparser/index.js +22 -8
  39. package/node_modules/nodemailer/lib/mime-funcs/mime-types.js +2 -0
  40. package/node_modules/nodemailer/lib/nodemailer.js +13 -6
  41. package/node_modules/nodemailer/lib/smtp-connection/index.js +9 -0
  42. package/node_modules/nodemailer/lib/well-known/services.json +14 -3
  43. package/node_modules/nodemailer/package.json +5 -5
  44. package/node_modules/tlds/index.json +0 -3
  45. package/node_modules/tlds/package.json +1 -1
  46. package/package.json +4 -4
  47. package/node_modules/libmime/node_modules/libbase64/.eslintrc +0 -11
  48. package/node_modules/libmime/node_modules/libbase64/.prettierrc.js +0 -8
  49. package/node_modules/libmime/node_modules/libbase64/LICENSE +0 -19
  50. package/node_modules/libmime/node_modules/libbase64/README.md +0 -113
  51. package/node_modules/libmime/node_modules/libbase64/lib/libbase64.js +0 -253
  52. package/node_modules/libmime/node_modules/libbase64/package.json +0 -35
  53. package/node_modules/libmime/node_modules/libqp/.eslintrc +0 -15
  54. package/node_modules/libmime/node_modules/libqp/.prettierrc.js +0 -8
  55. package/node_modules/libmime/node_modules/libqp/CHANGELOG.md +0 -8
  56. package/node_modules/libmime/node_modules/libqp/LICENSE +0 -19
  57. package/node_modules/libmime/node_modules/libqp/README.md +0 -119
  58. package/node_modules/libmime/node_modules/libqp/lib/libqp.js +0 -320
  59. package/node_modules/libmime/node_modules/libqp/package.json +0 -28
  60. package/node_modules/libmime/node_modules/libqp/test/libqp-test.js +0 -41
  61. package/node_modules/mailsplit/node_modules/encoding-japanese/LICENSE +0 -21
  62. package/node_modules/mailsplit/node_modules/encoding-japanese/README.md +0 -542
  63. package/node_modules/mailsplit/node_modules/encoding-japanese/encoding.js +0 -6077
  64. package/node_modules/mailsplit/node_modules/encoding-japanese/encoding.min.js +0 -8
  65. package/node_modules/mailsplit/node_modules/encoding-japanese/encoding.min.js.map +0 -1
  66. package/node_modules/mailsplit/node_modules/encoding-japanese/package.json +0 -70
  67. package/node_modules/mailsplit/node_modules/encoding-japanese/src/banner.js +0 -6
  68. package/node_modules/mailsplit/node_modules/encoding-japanese/src/config.js +0 -139
  69. package/node_modules/mailsplit/node_modules/encoding-japanese/src/encoding-convert.js +0 -1676
  70. package/node_modules/mailsplit/node_modules/encoding-japanese/src/encoding-detect.js +0 -502
  71. package/node_modules/mailsplit/node_modules/encoding-japanese/src/encoding-table.js +0 -4
  72. package/node_modules/mailsplit/node_modules/encoding-japanese/src/index.js +0 -593
  73. package/node_modules/mailsplit/node_modules/encoding-japanese/src/jis-to-utf8-table.js +0 -5
  74. package/node_modules/mailsplit/node_modules/encoding-japanese/src/jisx0212-to-utf8-table.js +0 -5
  75. package/node_modules/mailsplit/node_modules/encoding-japanese/src/kana-case-table.js +0 -41
  76. package/node_modules/mailsplit/node_modules/encoding-japanese/src/utf8-to-jis-table.js +0 -1493
  77. package/node_modules/mailsplit/node_modules/encoding-japanese/src/utf8-to-jisx0212-table.js +0 -1224
  78. package/node_modules/mailsplit/node_modules/encoding-japanese/src/util.js +0 -361
  79. package/node_modules/mailsplit/node_modules/libmime/.eslintrc +0 -7
  80. package/node_modules/mailsplit/node_modules/libmime/.gitattributes +0 -1
  81. package/node_modules/mailsplit/node_modules/libmime/.github/FUNDING.yml +0 -4
  82. package/node_modules/mailsplit/node_modules/libmime/.github/workflows/test.yml +0 -21
  83. package/node_modules/mailsplit/node_modules/libmime/.prettierrc.js +0 -8
  84. package/node_modules/mailsplit/node_modules/libmime/CHANGELOG.md +0 -110
  85. package/node_modules/mailsplit/node_modules/libmime/LICENSE +0 -19
  86. package/node_modules/mailsplit/node_modules/libmime/README.md +0 -207
  87. package/node_modules/mailsplit/node_modules/libmime/lib/charset.js +0 -117
  88. package/node_modules/mailsplit/node_modules/libmime/lib/charsets.js +0 -212
  89. package/node_modules/mailsplit/node_modules/libmime/lib/libmime.js +0 -903
  90. package/node_modules/mailsplit/node_modules/libmime/lib/mimetypes.js +0 -2049
  91. package/node_modules/mailsplit/node_modules/libmime/package.json +0 -37
  92. /package/node_modules/{libmime/node_modules/libbase64 → libbase64}/.github/FUNDING.yml +0 -0
  93. /package/node_modules/{libmime/node_modules/libbase64 → libbase64}/.github/workflows/release.yaml +0 -0
  94. /package/node_modules/{libmime/node_modules/libbase64 → libbase64}/.github/workflows/test.yml +0 -0
  95. /package/node_modules/{libmime/node_modules/libbase64 → libbase64}/.ncurc.js +0 -0
  96. /package/node_modules/{libmime/node_modules/libbase64 → libbase64}/CHANGELOG.md +0 -0
  97. /package/node_modules/{libmime/node_modules/libqp → libqp}/.github/FUNDING.yml +0 -0
  98. /package/node_modules/{libmime/node_modules/libqp → libqp}/.github/workflows/release.yaml +0 -0
  99. /package/node_modules/{libmime/node_modules/libqp → libqp}/.github/workflows/test.yml +0 -0
@@ -1,542 +0,0 @@
1
- encoding.js
2
- ===========
3
-
4
- [![NPM Version](https://img.shields.io/npm/v/encoding-japanese.svg)](https://www.npmjs.com/package/encoding-japanese)
5
- [![Build Status](https://app.travis-ci.com/polygonplanet/encoding.js.svg?branch=master)](https://app.travis-ci.com/polygonplanet/encoding.js)
6
- [![GitHub License](https://img.shields.io/github/license/polygonplanet/encoding.js.svg)](https://github.com/polygonplanet/encoding.js/blob/master/LICENSE)
7
-
8
- Convert or detect character encoding in JavaScript.
9
-
10
- [**README (Japanese)**](README_ja.md)
11
-
12
- ## Table of contents
13
-
14
- - [Features](#features)
15
- * [How to use character encoding in strings?](#how-to-use-character-encoding-in-strings)
16
- - [Installation](#installation)
17
- * [npm](#npm)
18
- + [TypeScript](#typescript)
19
- * [browser (standalone)](#browser-standalone)
20
- * [CDN](#cdn)
21
- - [Supported encodings](#supported-encodings)
22
- * [About `UNICODE`](#about-unicode)
23
- - [Example usage](#example-usage)
24
- - [Demo](#demo)
25
- - [API](#api)
26
- * [Detect character encoding (detect)](#detect-character-encoding-detect)
27
- * [Convert character encoding (convert)](#convert-character-encoding-convert)
28
- + [Specify conversion options to the argument `to_encoding` as an object](#specify-conversion-options-to-the-argument-to_encoding-as-an-object)
29
- + [Specify the return type by the `type` option](#specify-the-return-type-by-the-type-option)
30
- + [Replace to HTML entity (Numeric character reference) when cannot be represented](#replace-to-html-entity-numeric-character-reference-when-cannot-be-represented)
31
- + [Specify BOM in UTF-16](#specify-bom-in-utf-16)
32
- * [URL Encode/Decode](#url-encodedecode)
33
- * [Base64 Encode/Decode](#base64-encodedecode)
34
- * [Code array to string conversion (codeToString/stringToCode)](#code-array-to-string-conversion-codetostringstringtocode)
35
- * [Japanese Zenkaku/Hankaku conversion](#japanese-zenkakuhankaku-conversion)
36
- - [Other examples](#other-examples)
37
- * [Example using the XMLHttpRequest and Typed arrays (Uint8Array)](#example-using-the-xmlhttprequest-and-typed-arrays-uint8array)
38
- * [Convert encoding for file using the File APIs](#convert-encoding-for-file-using-the-file-apis)
39
- - [Contributing](#contributing)
40
- - [License](#license)
41
-
42
- ## Features
43
-
44
- encoding.js is a JavaScript library for converting and detecting character encodings
45
- that support Japanese character encodings such as `Shift_JIS`, `EUC-JP`, `JIS`, and `Unicode` such as `UTF-8` and `UTF-16`.
46
-
47
- Since JavaScript string values are internally encoded as UTF-16 code units ([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)),
48
- they cannot properly handle other character encodings as they are, but encoding.js enables conversion by handling them as arrays instead of strings.
49
-
50
- Each character encoding is handled as an array of numbers with character code values, for example `[130, 160]` ("あ" in UTF-8).
51
-
52
- The array of character codes passed to each method of encoding.js can also be used with TypedArray such as `Uint8Array`, and `Buffer` in Node.js.
53
-
54
- ### How to use character encoding in strings?
55
-
56
- Numeric arrays of character codes can be converted to strings with methods such as [`Encoding.codeToString`](#code-array-to-string-conversion-codetostringstringtocode) ,
57
- but because of the above JavaScript specifications, some character encodings cannot be handled properly when converted to strings.
58
-
59
- So if you want to use strings instead of arrays, convert it to percent-encoded strings like `'%82%A0'` by using [`Encoding.urlEncode`](#url-encodedecode) and [`Encoding.urlDecode`](#url-encodedecode) to passed to other resources.
60
- Or, [`Encoding.base64Encode`](#base64-encodedecode) and [`Encoding.base64Decode`](#base64-encodedecode) can be passed as strings in the same way.
61
-
62
- ## Installation
63
-
64
- ### npm
65
-
66
- encoding.js is published under the package name `encoding-japanese` on npm.
67
-
68
- ```bash
69
- $ npm install --save encoding-japanese
70
- ```
71
-
72
- #### using `import`
73
-
74
- ```javascript
75
- import Encoding from 'encoding-japanese';
76
- ```
77
-
78
- #### using `require`
79
-
80
- ```javascript
81
- const Encoding = require('encoding-japanese');
82
- ```
83
-
84
- #### TypeScript
85
-
86
- TypeScript type definitions for encoding.js are available at [@types/encoding-japanese](https://www.npmjs.com/package/@types/encoding-japanese) (thanks [@rhysd](https://github.com/rhysd)).
87
-
88
- ```bash
89
- $ npm install --save-dev @types/encoding-japanese
90
- ```
91
-
92
- ### browser (standalone)
93
-
94
- Install from npm or download from the [release list](https://github.com/polygonplanet/encoding.js/tags) and use `encoding.js` or `encoding.min.js` in the package.
95
- \*Please note that if you `git clone`, even the *master* branch may be under development.
96
-
97
- ```html
98
- <script src="encoding.js"></script>
99
- ```
100
-
101
- Or use the minified `encoding.min.js`
102
-
103
- ```html
104
- <script src="encoding.min.js"></script>
105
- ```
106
-
107
- When the script is loaded, the object `Encoding` is defined in the global scope (ie `window.Encoding`).
108
-
109
- ### CDN
110
-
111
- You can use the encoding.js (package name: `encoding-japanese`) CDN on [cdnjs.com](https://cdnjs.com/libraries/encoding-japanese).
112
-
113
- ## Supported encodings
114
-
115
- |Value in encoding.js|[`detect()`](#detect-character-encoding-detect)|[`convert()`](#convert-character-encoding-convert)|MIME Name (Note)|
116
- |:------:|:----:|:-----:|:---|
117
- |ASCII |✓ | |US-ASCII (Code point range: `0-127`)|
118
- |BINARY |✓ | |(Binary strings. Code point range: `0-255`)|
119
- |EUCJP |✓ |✓ |EUC-JP|
120
- |JIS |✓ |✓ |ISO-2022-JP|
121
- |SJIS |✓ |✓ |Shift_JIS|
122
- |UTF8 |✓ |✓ |UTF-8|
123
- |UTF16 |✓ |✓ |UTF-16|
124
- |UTF16BE |✓ |✓ |UTF-16BE (big-endian)|
125
- |UTF16LE |✓ |✓ |UTF-16LE (little-endian)|
126
- |UTF32 |✓ | |UTF-32|
127
- |UNICODE |✓ |✓ |(JavaScript's internal encoding. *See [About `UNICODE`](#about-unicode) below) |
128
-
129
- ### About `UNICODE`
130
-
131
- In encoding.js, the internal character encoding that can be handled in JavaScript is defined as `UNICODE`.
132
-
133
- As mentioned above ([Features](#features)), JavaScript strings are internally encoded in UTF-16 code units, and other character encodings cannot be handled properly.
134
- Therefore, to convert to a character encoding properly represented in JavaScript, specify `UNICODE`.
135
-
136
- (*Even if the HTML file encoding is UTF-8, specify `UNICODE` instead of `UTF8` when handling it in JavaScript.)
137
-
138
- The value of each character code array returned from `Encoding.convert` is a number of 0-255 if you specify a character code other than `UNICODE` such as `UTF8` or `SJIS`,
139
- or a number of `0-65535` (range of `String.prototype.charCodeAt()` values = Code Unit) if you specify `UNICODE`.
140
-
141
- ## Example usage
142
-
143
- Convert character encoding from JavaScript string (`UNICODE`) to `SJIS`.
144
-
145
- ```javascript
146
- const unicodeArray = Encoding.stringToCode('こんにちは'); // Convert string to code array
147
- const sjisArray = Encoding.convert(unicodeArray, {
148
- to: 'SJIS',
149
- from: 'UNICODE'
150
- });
151
- console.log(sjisArray);
152
- // [130, 177, 130, 241, 130, 201, 130, 191, 130, 205] ('こんにちは' array in SJIS)
153
- ```
154
-
155
- Convert character encoding from `SJIS` to `UNICODE`.
156
-
157
- ```javascript
158
- var sjisArray = [
159
- 130, 177, 130, 241, 130, 201, 130, 191, 130, 205
160
- ]; // 'こんにちは' array in SJIS
161
-
162
- var unicodeArray = Encoding.convert(sjisArray, {
163
- to: 'UNICODE',
164
- from: 'SJIS'
165
- });
166
- var str = Encoding.codeToString(unicodeArray); // Convert code array to string
167
- console.log(str); // 'こんにちは'
168
- ```
169
-
170
- Detect character encoding.
171
-
172
- ```javascript
173
- var data = [
174
- 227, 129, 147, 227, 130, 147, 227, 129, 171, 227, 129, 161, 227, 129, 175
175
- ]; // 'こんにちは' array in UTF-8
176
-
177
- var detectedEncoding = Encoding.detect(data);
178
- console.log('Character encoding is ' + detectedEncoding); // 'Character encoding is UTF8'
179
- ```
180
-
181
- (Node.js) Example of reading a text file written in `SJIS`.
182
-
183
- ```javascript
184
- const fs = require('fs');
185
- const Encoding = require('encoding-japanese');
186
-
187
- const sjisBuffer = fs.readFileSync('./sjis.txt');
188
- const unicodeArray = Encoding.convert(sjisBuffer, {
189
- to: 'UNICODE',
190
- from: 'SJIS'
191
- });
192
- console.log(Encoding.codeToString(unicodeArray));
193
- ```
194
-
195
- ## Demo
196
-
197
- * [Test for character encoding conversion (Demo)](http://polygonplanet.github.io/encoding.js/tests/encoding-test.html)
198
- * [Detect and Convert encoding from file (Demo)](http://polygonplanet.github.io/encoding.js/tests/detect-file-encoding.html)
199
-
200
- ----
201
-
202
- ## API
203
-
204
- * [detect](#detect-character-encoding-detect)
205
- * [convert](#convert-character-encoding-convert)
206
- * [urlEncode / urlDecode](#url-encodedecode)
207
- * [base64Encode / base64Decode](#base64-encodedecode)
208
- * [codeToString / stringToCode](#code-array-to-string-conversion-codetostringstringtocode)
209
- * [Japanese Zenkaku / Hankaku conversion](#japanese-zenkakuhankaku-conversion)
210
-
211
- ### Detect character encoding (detect)
212
-
213
- * {_string|boolean_} Encoding.**detect** ( data [, encodings ] )
214
- Detect character encoding.
215
- @param {_Array|TypedArray|string_} _data_ Target data
216
- @param {_string|Array_} [_encodings_] (Optional) The encoding name that to specify the detection (value of [Supported encodings](#supported-encodings))
217
- @return {_string|boolean_} Return the detected character encoding, or false.
218
-
219
- The return value is one of the above "[Supported encodings](#supported-encodings)" or false if it cannot be detected.
220
-
221
- ```javascript
222
- var sjisArray = [130, 168, 130, 205, 130, 230]; // 'おはよ' array in SJIS
223
- var detectedEncoding = Encoding.detect(sjisArray);
224
- console.log('Encoding is ' + detectedEncoding); // 'Encoding is SJIS'
225
- ```
226
-
227
- Example of specifying the character encoding to be detected.
228
- If the second argument `encodings` is specified, returns true when it is the specified character encoding, false otherwise.
229
-
230
- ```javascript
231
- var sjisArray = [130, 168, 130, 205, 130, 230];
232
- var isSJIS = Encoding.detect(sjisArray, 'SJIS');
233
- if (isSJIS) {
234
- console.log('Encoding is SJIS');
235
- }
236
- ```
237
-
238
- ### Convert character encoding (convert)
239
-
240
- * {_Array|TypedArray|string_} Encoding.**convert** ( data, to\_encoding [, from\_encoding ] )
241
- Converts character encoding.
242
- @param {_Array|TypedArray|Buffer|string_} _data_ The target data.
243
- @param {_string|Object_} _to\_encoding_ The encoding name of conversion destination, or option to convert as an object.
244
- @param {_string|Array_} [_from\_encoding_] (Optional) The encoding name of the source or 'AUTO'.
245
- @return {_Array|TypedArray|string_} Return the converted array/string.
246
-
247
- Example of converting a character code array to Shift_JIS from UTF-8.
248
-
249
- ```javascript
250
- var utf8Array = [227, 129, 130]; // "あ" in UTF-8
251
- var sjisArray = Encoding.convert(utf8Array, 'SJIS', 'UTF8');
252
- console.log(sjisArray); // [130, 160] ("あ" in SJIS)
253
- ```
254
-
255
- TypedArray such as `Uint8Array`, and `Buffer` of Node.js can be converted in the same usage.
256
-
257
- ```javascript
258
- var utf8Array = new Uint8Array([227, 129, 130]);
259
- Encoding.convert(utf8Array, 'SJIS', 'UTF8');
260
- ```
261
-
262
- Converts character encoding by auto-detecting the encoding name of the source.
263
-
264
- ```javascript
265
- // The character encoding is automatically detected when the from_encoding argument is omitted
266
- var utf8Array = [227, 129, 130];
267
- var sjisArray = Encoding.convert(utf8Array, 'SJIS');
268
-
269
- // Or explicitly specify 'AUTO' to auto-detecting
270
- sjisArray = Encoding.convert(utf8Array, 'SJIS', 'AUTO');
271
- ```
272
-
273
- #### Specify conversion options to the argument `to_encoding` as an object
274
-
275
- You can specify the second argument `to_encoding` as an object for improving readability.
276
-
277
- ```javascript
278
- var sjisArray = Encoding.convert(utf8Array, {
279
- to: 'SJIS', // to_encoding
280
- from: 'UTF8' // from_encoding
281
- });
282
- ```
283
-
284
- #### Specify the return type by the `type` option
285
-
286
- `convert` returns an array by default, but you can change the return type by specifying the `type` option.
287
- Also, if the argument `data` is passed as a string and the` type` option is not specified, then `type` ='string' is assumed (returns as a string).
288
-
289
- ```javascript
290
- var sjisArray = [130, 168, 130, 205, 130, 230]; // 'おはよ' array in SJIS
291
- var unicodeString = Encoding.convert(sjisArray, {
292
- to: 'UNICODE',
293
- from: 'SJIS',
294
- type: 'string' // Specify 'string' to return as string
295
- });
296
- console.log(unicodeString); // 'おはよ'
297
- ```
298
-
299
- The following `type` options are supported
300
-
301
- * **string** : Return as a string
302
- * **arraybuffer** : Return as an ArrayBuffer (`Uint16Array`)
303
- * **array** : Return as an Array (*default*)
304
-
305
- #### Replace to HTML entity (Numeric character reference) when cannot be represented
306
-
307
- Characters that cannot be represented in the target character set are replaced with '?' (U+003F) by default but can be replaced with HTML entities by specifying the `fallback` option.
308
-
309
- The `fallback` option supports the following values.
310
-
311
- * **html-entity** : Replace to HTML entity (decimal HTML numeric character reference)
312
- * **html-entity-hex** : Replace to HTML entity (hexadecimal HTML numeric character reference)
313
-
314
- Example of specifying `{ fallback: 'html-entity' }` option
315
-
316
- ```javascript
317
- var unicodeArray = Encoding.stringToCode('寿司🍣ビール🍺');
318
- // No fallback specified
319
- var sjisArray = Encoding.convert(unicodeArray, {
320
- to: 'SJIS',
321
- from: 'UNICODE'
322
- });
323
- console.log(sjisArray); // Converted to a code array of '寿司?ビール?'
324
-
325
- // Specify `fallback: html-entity`
326
- sjisArray = Encoding.convert(unicodeArray, {
327
- to: 'SJIS',
328
- from: 'UNICODE',
329
- fallback: 'html-entity'
330
- });
331
- console.log(sjisArray); // Converted to a code array of '寿司&#127843;ビール&#127866;'
332
- ```
333
-
334
- Example of specifying `{ fallback: 'html-entity-hex' }` option
335
-
336
- ```javascript
337
- var unicodeArray = Encoding.stringToCode('ホッケの漢字は𩸽');
338
- var sjisArray = Encoding.convert(unicodeArray, {
339
- to: 'SJIS',
340
- from: 'UNICODE',
341
- fallback: 'html-entity-hex'
342
- });
343
- console.log(sjisArray); // Converted to a code array of 'ホッケの漢字は&#x29e3d;'
344
- ```
345
-
346
- #### Specify BOM in UTF-16
347
-
348
- You can add a BOM (byte order mark) by specifying the `bom` option when converting to `UTF16`.
349
- The default is no BOM.
350
-
351
- ```javascript
352
- var utf16Array = Encoding.convert(utf8Array, {
353
- to: 'UTF16', // to_encoding
354
- from: 'UTF8', // from_encoding
355
- bom: true // Add BOM
356
- });
357
- ```
358
-
359
- `UTF16` byte order is big-endian by default.
360
- If you want to convert as little-endian, specify the `{ bom: 'LE' }` option.
361
-
362
- ```javascript
363
- var utf16leArray = Encoding.convert(utf8Array, {
364
- to: 'UTF16', // to_encoding
365
- from: 'UTF8', // from_encoding
366
- bom: 'LE' // With BOM (little-endian)
367
- });
368
- ```
369
-
370
- If you do not need BOM, use `UTF16BE` or `UTF16LE`.
371
- `UTF16BE` is big-endian, and `UTF16LE` is little-endian, and both have no BOM.
372
-
373
- ```javascript
374
- var utf16beArray = Encoding.convert(utf8Array, {
375
- to: 'UTF16BE',
376
- from: 'UTF8'
377
- });
378
- ```
379
-
380
- ### URL Encode/Decode
381
-
382
- * {_string_} Encoding.**urlEncode** ( data )
383
- URL(percent) encode.
384
- @param {_Array_|_TypedArray_} _data_ Target data.
385
- @return {_string_} Return the encoded string.
386
-
387
- * {_Array_} Encoding.**urlDecode** ( string )
388
- URL(percent) decode.
389
- @param {_string_} _string_ Target data.
390
- @return {_Array_} Return the decoded array.
391
-
392
- ```javascript
393
- var sjisArray = [130, 177, 130, 241, 130, 201, 130, 191, 130, 205];
394
- var encoded = Encoding.urlEncode(sjisArray);
395
- console.log(encoded); // '%82%B1%82%F1%82%C9%82%BF%82%CD'
396
-
397
- var decoded = Encoding.urlDecode(encoded);
398
- console.log(decoded); // [130, 177, 130, 241, 130, 201, 130, 191, 130, 205]
399
- ```
400
-
401
- ### Base64 Encode/Decode
402
-
403
- * {_string_} Encoding.**base64Encode** ( data )
404
- Base64 encode.
405
- @param {_Array_|_TypedArray_} _data_ Target data.
406
- @return {_string_} Return the Base64 encoded string.
407
-
408
- * {_Array_} Encoding.**base64Decode** ( string )
409
- Base64 decode.
410
- @param {_string_} _string_ Target data.
411
- @return {_Array_} Return the Base64 decoded array.
412
-
413
- ```javascript
414
- var sjisArray = [130, 177, 130, 241, 130, 201, 130, 191, 130, 205];
415
- var encoded = Encoding.base64Encode(sjisArray);
416
- console.log(encoded); // 'grGC8YLJgr+CzQ=='
417
-
418
- var decoded = Encoding.base64Decode(encoded);
419
- console.log(decoded); // [130, 177, 130, 241, 130, 201, 130, 191, 130, 205]
420
- ```
421
-
422
- ### Code array to string conversion (codeToString/stringToCode)
423
-
424
- * {_string_} Encoding.**codeToString** ( {_Array_|_TypedArray_} data )
425
- Joins a character code array to string.
426
-
427
- * {_Array_} Encoding.**stringToCode** ( {_string_} string )
428
- Splits string to an array of character codes.
429
-
430
- ### Japanese Zenkaku/Hankaku conversion
431
-
432
- * {_Array|string_} Encoding.**toHankakuCase** ( {_Array|string_} data )
433
- Convert the ascii symbols and alphanumeric characters to the zenkaku symbols and alphanumeric characters.
434
-
435
- * {_Array|string_} Encoding.**toZenkakuCase** ( {_Array|string_} data )
436
- Convert to the zenkaku symbols and alphanumeric characters from the ascii symbols and alphanumeric characters.
437
-
438
- * {_Array|string_} Encoding.**toHiraganaCase** ( {_Array|string_} data )
439
- Convert to the zenkaku hiragana from the zenkaku katakana.
440
-
441
- * {_Array|string_} Encoding.**toKatakanaCase** ( {_Array|string_} data )
442
- Convert to the zenkaku katakana from the zenkaku hiragana.
443
-
444
- * {_Array|string_} Encoding.**toHankanaCase** ( {_Array|string_} data )
445
- Convert to the hankaku katakana from the zenkaku katakana.
446
-
447
- * {_Array|string_} Encoding.**toZenkanaCase** ( {_Array|string_} data )
448
- Convert to the zenkaku katakana from the hankaku katakana.
449
-
450
- * {_Array|string_} Encoding.**toHankakuSpace** ({_Array|string_} data )
451
- Convert the em space(U+3000) to the single space(U+0020).
452
-
453
- * {_Array|string_} Encoding.**toZenkakuSpace** ( {_Array|string_} data )
454
- Convert the single space(U+0020) to the em space(U+3000).
455
-
456
- ## Other examples
457
-
458
- ### Example using the XMLHttpRequest and Typed arrays (Uint8Array)
459
-
460
- This sample reads the text file written in Shift_JIS as binary data,
461
- and displays a string that is converted to Unicode by Encoding.convert.
462
-
463
- ```javascript
464
- var req = new XMLHttpRequest();
465
- req.open('GET', '/my-shift_jis.txt', true);
466
- req.responseType = 'arraybuffer';
467
-
468
- req.onload = function (event) {
469
- var buffer = req.response;
470
- if (buffer) {
471
- // Shift_JIS Array
472
- var sjisArray = new Uint8Array(buffer);
473
-
474
- // Convert encoding to UNICODE (JavaScript Unicode Array).
475
- var unicodeArray = Encoding.convert(sjisArray, {
476
- to: 'UNICODE',
477
- from: 'SJIS'
478
- });
479
-
480
- // Join to string.
481
- var unicodeString = Encoding.codeToString(unicodeArray);
482
- console.log(unicodeString);
483
- }
484
- };
485
-
486
- req.send(null);
487
- ```
488
-
489
- ### Convert encoding for file using the File APIs
490
-
491
- Reads file using the File APIs.
492
- Detect file encoding and convert to Unicode, and display it.
493
-
494
- ```html
495
- <input type="file" id="file">
496
- <div id="encoding"></div>
497
- <textarea id="result" rows="5" cols="80"></textarea>
498
-
499
- <script>
500
- function onFileSelect(event) {
501
- var file = event.target.files[0];
502
-
503
- var reader = new FileReader();
504
- reader.onload = function(e) {
505
- var codes = new Uint8Array(e.target.result);
506
- var encoding = Encoding.detect(codes);
507
- document.getElementById('encoding').textContent = encoding;
508
-
509
- // Convert encoding to unicode
510
- var unicodeString = Encoding.convert(codes, {
511
- to: 'unicode',
512
- from: encoding,
513
- type: 'string'
514
- });
515
- document.getElementById('result').value = unicodeString;
516
- };
517
-
518
- reader.readAsArrayBuffer(file);
519
- }
520
-
521
- document.getElementById('file').addEventListener('change', onFileSelect, false);
522
- </script>
523
- ```
524
-
525
- [**Demo**](http://polygonplanet.github.io/encoding.js/tests/detect-file-encoding.html)
526
-
527
- ## Contributing
528
-
529
- We welcome contributions from everyone.
530
- For bug reports and feature requests, please [create an issue on GitHub](https://github.com/polygonplanet/encoding.js/issues).
531
-
532
- ### Pull requests
533
-
534
- Please run `$ npm run test` before the pull request to confirm there are no errors.
535
- We only accept requests without errors.
536
-
537
- ## License
538
-
539
- MIT
540
-
541
-
542
-