簡體   English   中英

Javascript:十六進制轉字符串,無需轉換為 ascii、int 或 xyz

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM