From a04d39a3cbf10e7335889615a36a78827857b566 Mon Sep 17 00:00:00 2001 From: destruc7i0n Date: Wed, 29 Dec 2021 16:39:46 -0500 Subject: escape unicode characters closes #76 --- src/lib/util.ts | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 src/lib/util.ts (limited to 'src/lib') diff --git a/src/lib/util.ts b/src/lib/util.ts new file mode 100644 index 0000000..bd94795 --- /dev/null +++ b/src/lib/util.ts @@ -0,0 +1,4 @@ +export const escapeUnicode = (str: string) => + str.replace(/[^\x00-\x7F]/g, (char: string) => '\\u' + char.charCodeAt(0).toString(16).padStart(4, '0')) + +export const fixMinecraftUsername = (username: string) => username.replace(/(ยง[A-Z-a-z0-9])/g, '') -- cgit 1.4.1