utf8BytesHex
This converts a unicode character into the UTF-8 bytes and returns the output as hex.
Created by: hackvertor
Installed 1 times
Category: Charsets
Created on: Monday, November 18, 2024 at 3:25:36 PM
Updated on: Tuesday, January 21, 2025 at 3:20:56 PM
Tag arguments
[]
Code
class utf8BytesHex {
encode(input) {
const encoder = new TextEncoder();
const utf8Array = encoder.encode(input);
return Array.from(utf8Array)
.map((byte) => "0x" + byte.toString(16).toUpperCase().padStart(2, "0"))
.join(" ");
}
}