Replace replacement character

See https://github.com/confio/cosmjs-types/issues/92
This commit is contained in:
Simon Warta
2024-03-08 11:08:45 +01:00
parent 11ce1223f0
commit f3bf99da07
2 changed files with 10 additions and 2 deletions
+3 -2
View File
@@ -15,8 +15,9 @@ export function toUtf8(str: string): Uint8Array {
/**
* Takes UTF-8 data and decodes it to a string.
*
* In lossy mode, the replacement character is used to substitude invalid
* encodings. By default lossy mode is off and invalid data will lead to exceptions.
* In lossy mode, the [REPLACEMENT CHARACTER](https://en.wikipedia.org/wiki/Specials_(Unicode_block))
* is used to substitude invalid encodings.
* By default lossy mode is off and invalid data will lead to exceptions.
*/
export function fromUtf8(data: Uint8Array, lossy = false): string {
const fatal = !lossy;