@lppedd/kotlinx-charset 0.0.1 → 0.0.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 CHANGED
@@ -1,11 +1,11 @@
1
1
  # kotlinx-charset
2
2
 
3
- Charset support for Kotlin Multiplatform.
3
+ Minimal charset support for Kotlin Multiplatform.
4
4
 
5
5
  ## core
6
6
 
7
- The `core` module provides the building blocks to implement new charsets,
8
- and to store them in a registry.
7
+ The `core` module provides the foundational components for implementing
8
+ and registering new charsets.
9
9
 
10
10
  ```kotlin
11
11
  // Create an empty charset registry
@@ -48,15 +48,22 @@ The `exported` module allows JS (and soon WebAssembly) consumers to decode bytes
48
48
  and encode strings, using top-level functions exported via ECMAScript modules.
49
49
 
50
50
  > [!TIP]
51
- > If you are consuming kotlinx-charset from a Kotlin project, avoid using this module
51
+ > Avoid using this module when consuming `kotlinx-charset` from a Kotlin project
52
52
 
53
+ You can depend on the [@lppedd/kotlinx-charset][1] npm package.
53
54
  For example, consuming the library from TypeScript would look like:
54
55
 
55
56
  ```ts
56
57
  import { decode, encode } from "@lppedd/kotlinx-charset";
57
58
 
58
- function example(toDecode: Uint8Array): void {
59
- const str = decode(toDecode);
60
- const bytes = encode(str);
59
+ function example(bytes: Uint8Array): Uint8Array {
60
+ const str = decode("cp037", bytes);
61
+ return encode("cp037", str);
61
62
  }
62
63
  ```
64
+
65
+ Both the `decode` and `encode` functions will throw an `Error`
66
+ if the specified charset does not exist or if an error occurs
67
+ during data processing.
68
+
69
+ [1]: https://www.npmjs.com/package/@lppedd/kotlinx-charset