From 3c0a9ade45d19d30aa879b66f812cba97a111ff7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20P=C3=A4per?= Date: Thu, 29 Jun 2023 12:53:06 +0200 Subject: [PATCH] Update toUnicode.js use codePointAt() to support more than just the BMP --- Scripts/toUnicode.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Scripts/toUnicode.js b/Scripts/toUnicode.js index 9b770400..031c554c 100644 --- a/Scripts/toUnicode.js +++ b/Scripts/toUnicode.js @@ -3,7 +3,7 @@ { "api":1, "name":"To Unicode Escaped String", - "description":"Converts a UTF8 string to unicode escape chars(js format)", + "description":"Converts a string to Unicode escape chars (JS format)", "author":"luisfontes19", "icon":"broom", "tags":"string,unicode,convert,escape" @@ -16,9 +16,9 @@ function main(state) { function toUnicode(str) { return [...str].map(c => { - let hex = c.charCodeAt(0).toString(16); + let hex = c.codePointAt(0).toString(16); if (hex.length == 2) hex = "00" + hex; - return ("\\u" + hex).slice(-7); + return ("\\u{" + hex + "}"); }).join(""); }