[英]Javascript: Hex to String without converting to ascii, int or xyz
我有一個字節數組
sensor_id = [bytes[36],bytes[35],bytes[34],bytes[33]]
它包含以下十六進制
0x69, 0x72, 0x33, 0x88
我需要將 69 72 33 88 合並到一個沒有對話的字符串值 => "69723388"。
謝謝你的幫助
您可以使用toString(16)
將十六進制值轉換為字符串。 有關更多信息,請閱讀MDN 文檔。
const arr = [0x69, 0x72, 0x33, 0x88]; const base16string = arr.map(item => item.toString(16)); console.log(base16string);
.as-console-wrapper {min-height: 100%!important; top: 0}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.