![](/img/trans.png)
[英]Trying to use iconv to convert US-ASCII to UTF-16LE and getting undesired output
[英]How to use iconv or similar to convert a UTF-16BE string to human readable characters
我在UTF-16BE
中有以下數據:
00 33 00 33 00 30 00 33 00 20 00 43 00 39 00 32 00 00
我正在嘗試將其轉換為人類可讀的格式,以便在 bash 腳本中進一步使用。
以上應解析為“ 3303 C92
”
目前我已經做到了這一點,但我顯然出錯了。
iconv -f UTF-16BE -t ASCII /home/code.txt #string above is only thing in this file.
命令錯誤: iconv: illegal input sequence at position 0
我正在使用 RHEL 7
最后一個字節 (00) 是額外的。
> base64 -d <<<"ADMAMwAwADMAIABDADkAMgA=" | iconv -f utf-16be -t ascii
3303 C92iconv: incomplete character or shift sequence at end of buffer
刪除最后一個字節后:
> base64 -d <<<"ADMAMwAwADMAIABDADkAMg==" | iconv -f utf-16be -t ascii
3303 C92
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.