[英]A unicode to character converter with text input and javascript
我正在制作一個工具,可以使用文本輸入和 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="\가"/> ➜char <input type="text" id="char"/>
我想做出正確的input
來呈現 '高興',這是\가
的字符值。 我應該進行哪些編輯? 我已經在 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="\가"/> ➜char <input type="text" id="char"/>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.