@cosmjs/encoding
Advanced tools
Comparing version 0.29.2 to 0.29.3
export declare function toUtf8(str: string): Uint8Array; | ||
export declare function fromUtf8(data: Uint8Array): string; | ||
/** | ||
* 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. | ||
*/ | ||
export declare function fromUtf8(data: Uint8Array, lossy?: boolean): string; |
@@ -8,6 +8,13 @@ "use strict"; | ||
exports.toUtf8 = toUtf8; | ||
function fromUtf8(data) { | ||
return new TextDecoder("utf-8", { fatal: true }).decode(data); | ||
/** | ||
* 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. | ||
*/ | ||
function fromUtf8(data, lossy = false) { | ||
const fatal = !lossy; | ||
return new TextDecoder("utf-8", { fatal }).decode(data); | ||
} | ||
exports.fromUtf8 = fromUtf8; | ||
//# sourceMappingURL=utf8.js.map |
{ | ||
"name": "@cosmjs/encoding", | ||
"version": "0.29.2", | ||
"version": "0.29.3", | ||
"description": "Encoding helpers for blockchain projects", | ||
@@ -5,0 +5,0 @@ "contributors": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24562
308