-
-
Notifications
You must be signed in to change notification settings - Fork 507
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Support unicode in REPL query param (#1162)
- Loading branch information
1 parent
aeb46af
commit d986799
Showing
3 changed files
with
25 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* Encode text to base64 with unicode support | ||
* | ||
* @param {string} text | ||
*/ | ||
export function textToBase64(text) { | ||
const bytes = new TextEncoder().encode(text); | ||
return btoa(String.fromCharCode(...bytes)); | ||
} | ||
|
||
/** | ||
* Decode text from base64 with unicode support | ||
* | ||
* @param {string} base64 | ||
*/ | ||
export function base64ToText(base64) { | ||
const bytes = Uint8Array.from(atob(base64), c => c.charCodeAt(0)); | ||
return new TextDecoder().decode(bytes); | ||
} |