@lppedd/kotlinx-charset 0.0.3 → 0.0.4
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/README.md +20 -7
- package/kotlinx-charset-exported.mjs +367 -125
- package/kotlinx-charset-exported.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,9 +37,10 @@ val encoder = charset.newEncoder()
|
|
|
37
37
|
The `ebcdic` module adds support for:
|
|
38
38
|
|
|
39
39
|
```text
|
|
40
|
-
IBM037
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
IBM037 IBM939
|
|
41
|
+
IBM273 IBM1047
|
|
42
|
+
IBM297 IBM1141
|
|
43
|
+
IBM930 IBM1147
|
|
43
44
|
```
|
|
44
45
|
|
|
45
46
|
You can register supported EBCDIC charsets to your `XCharsetRegistrar`
|
|
@@ -66,11 +67,23 @@ You can depend on the [@lppedd/kotlinx-charset][1] npm package.
|
|
|
66
67
|
For example, consuming the library from TypeScript would look like:
|
|
67
68
|
|
|
68
69
|
```ts
|
|
69
|
-
import { decode, encode } from "@lppedd/kotlinx-charset";
|
|
70
|
+
import { decode, encode, getCharset } from "@lppedd/kotlinx-charset";
|
|
70
71
|
|
|
71
|
-
function
|
|
72
|
-
const str = decode("
|
|
73
|
-
return encode("
|
|
72
|
+
function funsExample(bytes: Uint8Array): Uint8Array {
|
|
73
|
+
const str = decode("ibm037", bytes);
|
|
74
|
+
return encode("ibm037", str);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Alternatively, you can interact with a charset instance directly.
|
|
78
|
+
// This allows setting or removing (by passing null) the replacement character.
|
|
79
|
+
function instanceExample(bytes: Uint8Array): Uint8Array {
|
|
80
|
+
const charset = getCharset("ibm037");
|
|
81
|
+
|
|
82
|
+
const decoder = charset.newDecoder();
|
|
83
|
+
const str = decoder.decode(bytes);
|
|
84
|
+
|
|
85
|
+
const encoder = charset.newEncoder();
|
|
86
|
+
return encoder.encode(str);
|
|
74
87
|
}
|
|
75
88
|
```
|
|
76
89
|
|