@lppedd/kotlinx-charset 0.0.3 → 0.1.1

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 CHANGED
@@ -37,16 +37,17 @@ val encoder = charset.newEncoder()
37
37
  The `ebcdic` module adds support for:
38
38
 
39
39
  ```text
40
- IBM037
41
- IBM930
42
- IBM1047
40
+ IBM037 IBM939 IBM1390
41
+ IBM273 IBM1047 IBM1399
42
+ IBM297 IBM1141
43
+ IBM930 IBM1147
43
44
  ```
44
45
 
45
46
  You can register supported EBCDIC charsets to your `XCharsetRegistrar`
46
47
  via the `provideCharsets` function.
47
48
 
48
49
  ```kotlin
49
- import com.github.lppedd.kotlinx.charset.ebcdic.provideCharsets as provideEbcdicCharsets
50
+ import com.lppedd.kotlinx.charset.ebcdic.provideCharsets as provideEbcdicCharsets
50
51
 
51
52
  // Your shared charset registry
52
53
  private val registrar = 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 example(bytes: Uint8Array): Uint8Array {
72
- const str = decode("cp037", bytes);
73
- return encode("cp037", str);
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
 
@@ -1,14 +1,11 @@
1
1
  type Nullable<T> = T | null | undefined
2
- export declare function getCharset(charsetName: string): XCharset;
3
- export declare function decode(charsetName: string, bytes: Uint8Array): string;
4
- export declare function encode(charsetName: string, value: string): Uint8Array;
5
2
  export declare interface XCharset {
6
3
  readonly name: string;
7
4
  readonly aliases: Array<string>;
8
5
  newDecoder(): XCharsetDecoder;
9
6
  newEncoder(): XCharsetEncoder;
10
7
  readonly __doNotUseOrImplementIt: {
11
- readonly "com.github.lppedd.kotlinx.charset.exported.XCharset": unique symbol;
8
+ readonly "com.lppedd.kotlinx.charset.exported.XCharset": unique symbol;
12
9
  };
13
10
  }
14
11
  export declare interface XCharsetDecoder {
@@ -16,7 +13,7 @@ export declare interface XCharsetDecoder {
16
13
  setReplacement(newReplacement: Nullable<string>): void;
17
14
  reset(): void;
18
15
  readonly __doNotUseOrImplementIt: {
19
- readonly "com.github.lppedd.kotlinx.charset.exported.XCharsetDecoder": unique symbol;
16
+ readonly "com.lppedd.kotlinx.charset.exported.XCharsetDecoder": unique symbol;
20
17
  };
21
18
  }
22
19
  export declare interface XCharsetEncoder {
@@ -24,6 +21,9 @@ export declare interface XCharsetEncoder {
24
21
  setReplacement(newReplacement: Nullable<Uint8Array>): void;
25
22
  reset(): void;
26
23
  readonly __doNotUseOrImplementIt: {
27
- readonly "com.github.lppedd.kotlinx.charset.exported.XCharsetEncoder": unique symbol;
24
+ readonly "com.lppedd.kotlinx.charset.exported.XCharsetEncoder": unique symbol;
28
25
  };
29
- }
26
+ }
27
+ export declare function getCharset(charsetName: string): XCharset;
28
+ export declare function decode(charsetName: string, bytes: Uint8Array): string;
29
+ export declare function encode(charsetName: string, value: string): Uint8Array;