亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Encoding 字符編碼的問題

Encoding 字符編碼的問題

C#
牧羊人nacy 2018-12-12 14:08:16
socket.send 發送的字符串,如下 <br> strS = "6800000000000068010243C3D916" <br> Byte[] bytesSent = Encoding.Unicode.GetBytes(strS); <br> socket.Send(bytesSent, bytesSent.Length, 0); <br> <br> <br> 接收到的怎么是些這樣的內容。而不是我發送的包. <br> 用別的測試工具發下去,接收的顯示正常。 <br> &lt; &lt;--服務器已收到:(56)6 <br> &lt; &lt;--36&nbsp; 00&nbsp; 38&nbsp; 00&nbsp; 30&nbsp; 00&nbsp; 30&nbsp; 00&nbsp; 30&nbsp; 00&nbsp; 30&nbsp; 00&nbsp; 30&nbsp; 00&nbsp; 30&nbsp; 00&nbsp; 30&nbsp; 00&nbsp; 30&nbsp; 00&nbsp; 30&nbsp; 00&nbsp; 30&nbsp; 00&nbsp; 30&nbsp; 00&nbsp; 30&nbsp; 00&nbsp; 36&nbsp; 00&nbsp; 38&nbsp; 00&nbsp; 30&nbsp; 00&nbsp; 31&nbsp; 00&nbsp; 30&nbsp; 00&nbsp; 32&nbsp; 00&nbsp; 34&nbsp; 00&nbsp; 33&nbsp; 00&nbsp; 43&nbsp; 00&nbsp; 33&nbsp; 00&nbsp; 44&nbsp; 00&nbsp; 39&nbsp; 00&nbsp; 31&nbsp; 00&nbsp; 36&nbsp; 00&nbsp; <br> <br> <br> 可能是Encoding轉換有問題,C#能用的編碼都試了,還是不行。誰知道請指教,多謝了。 <br> Encoding.Unicode <br> ASCII <br> Default <br> UTF32 <br> UTF8 <br> UTF7 <br> 這些都試過,不行。
查看完整描述

2 回答

?
慕碼人8056858

TA貢獻1803條經驗 獲得超6個贊

36 00 38 00 30 00 30 00 30 00 30 00 30 00 30 00 30 00 30 00 30 00 30 00 30 00 30 00 36 00 38 00 30 00 31 00 30 00 32 00 34 00 33 00 43 00 33 00 44 00 39 00 31 00 36 00 這個序列是你服務器打印的還是其他工具打印的?這個序列是正確的,和下面代碼轉換 出來的字節序列是一樣的。只不過是16進制表示。 strS = "6800000000000068010243C3D916" Byte[] bytesSent = Encoding.Unicode.GetBytes(strS);

查看完整回答
反對 回復 2018-12-16
?
湖上湖

TA貢獻2003條經驗 獲得超2個贊

Encoding.Unicode 的意思,好象是 UTF16, 每個字符,不論中英文,都是用兩位 byte 來表示。

老兄的意思,可能是要用 Encoding.UTF8 來處理。


查看完整回答
反對 回復 2018-12-16
  • 2 回答
  • 0 關注
  • 744 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號