@lppedd/kotlinx-charset 0.0.4 → 0.1.2
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 +18 -5
- package/kotlinx-charset-exported.d.ts +8 -7
- package/kotlinx-charset-exported.mjs +3409 -1757
- package/kotlinx-charset-exported.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|

|
|
4
4
|

|
|
5
5
|

|
|
6
|
+
[](https://mvnrepository.com/artifact/com.lppedd.kotlinx-charset)
|
|
6
7
|
|
|
7
8
|
Minimal charset support for Kotlin Multiplatform.
|
|
8
9
|
|
|
@@ -12,7 +13,19 @@ See [CHANGELOG.md](./CHANGELOG.md).
|
|
|
12
13
|
|
|
13
14
|
### Supported Kotlin platforms
|
|
14
15
|
|
|
15
|
-
All Kotlin platforms are supported, except for Android.
|
|
16
|
+
All Kotlin platforms are supported, except for Android Native.
|
|
17
|
+
|
|
18
|
+
### Design considerations
|
|
19
|
+
|
|
20
|
+
**kotlinx-charset** aims to be straightforward for existing JDK consumers.
|
|
21
|
+
It replicates parts of the JDK's `Charset` API, albeit with more restrictions.
|
|
22
|
+
|
|
23
|
+
The core types you will work with are:
|
|
24
|
+
|
|
25
|
+
- `XCharset` - describes a character set
|
|
26
|
+
- `XCharsetDecoder` - decodes a byte sequence into characters
|
|
27
|
+
- `XCharsetEncoder` - encodes characters into a byte sequence
|
|
28
|
+
- `XCharsetRegistrar` - a registry and lookup service for obtaining `XCharset` instances
|
|
16
29
|
|
|
17
30
|
## core
|
|
18
31
|
|
|
@@ -27,7 +40,7 @@ private val registrar = XCharsetRegistrar()
|
|
|
27
40
|
registrar.registerCharset(YourCharset())
|
|
28
41
|
|
|
29
42
|
// Retrieve and use a charset
|
|
30
|
-
val charset = registrar.getCharset("
|
|
43
|
+
val charset = registrar.getCharset("YourCharsetName")
|
|
31
44
|
val decoder = charset.newDecoder()
|
|
32
45
|
val encoder = charset.newEncoder()
|
|
33
46
|
```
|
|
@@ -37,8 +50,8 @@ val encoder = charset.newEncoder()
|
|
|
37
50
|
The `ebcdic` module adds support for:
|
|
38
51
|
|
|
39
52
|
```text
|
|
40
|
-
IBM037 IBM939
|
|
41
|
-
IBM273 IBM1047
|
|
53
|
+
IBM037 IBM939 IBM1390
|
|
54
|
+
IBM273 IBM1047 IBM1399
|
|
42
55
|
IBM297 IBM1141
|
|
43
56
|
IBM930 IBM1147
|
|
44
57
|
```
|
|
@@ -47,7 +60,7 @@ You can register supported EBCDIC charsets to your `XCharsetRegistrar`
|
|
|
47
60
|
via the `provideCharsets` function.
|
|
48
61
|
|
|
49
62
|
```kotlin
|
|
50
|
-
import com.
|
|
63
|
+
import com.lppedd.kotlinx.charset.ebcdic.provideCharsets as provideEbcdicCharsets
|
|
51
64
|
|
|
52
65
|
// Your shared charset registry
|
|
53
66
|
private val registrar = XCharsetRegistrar()
|
|
@@ -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.
|
|
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.
|
|
16
|
+
readonly "com.lppedd.kotlinx.charset.exported.XCharsetDecoder": unique symbol;
|
|
20
17
|
};
|
|
21
18
|
}
|
|
22
19
|
export declare interface XCharsetEncoder {
|
|
@@ -24,6 +21,10 @@ export declare interface XCharsetEncoder {
|
|
|
24
21
|
setReplacement(newReplacement: Nullable<Uint8Array>): void;
|
|
25
22
|
reset(): void;
|
|
26
23
|
readonly __doNotUseOrImplementIt: {
|
|
27
|
-
readonly "com.
|
|
24
|
+
readonly "com.lppedd.kotlinx.charset.exported.XCharsetEncoder": unique symbol;
|
|
28
25
|
};
|
|
29
|
-
}
|
|
26
|
+
}
|
|
27
|
+
export declare function getCharsets(): Array<XCharset>;
|
|
28
|
+
export declare function getCharset(charsetName: string): XCharset;
|
|
29
|
+
export declare function decode(charsetName: string, bytes: Uint8Array): string;
|
|
30
|
+
export declare function encode(charsetName: string, value: string): Uint8Array;
|