具有文本输入和javascript的unicode到字符转换器



我正在制作一个工具,通过文本输入和javascript将unicode值转换为字符。

以下是我到目前为止所做的工作,我对Javascript还很陌生,所以我认为代码看起来很奇怪:

setInterval(
function tochar() {
const hex = +document.getElementById('hex').value;
const char = hex.toString();
document.getElementById("char").value = char;
});
unicode <input type="text" id="hex" value="uac00"/>
➜char <input type="text" id="char"/>

我想制作正确的input来渲染'가',这是CCD_ 2的字符值。我应该做哪些编辑?我已经参考了关于StackOverflow和其他来源的许多问答,但找不到对我有用的东西。

function tochar() {
// Get input
let hex = document.getElementById('hex').value;

// Remove u
hex = hex.slice(2);

// Convert to char
const char = String.fromCharCode(parseInt(hex,16));

// Show
document.getElementById("char").value = char;
};
tochar();
unicode <input type="text" id="hex" value="uac00"/>
➜char <input type="text" id="char"/>

最新更新