有关streamreader.read的问题,十六进制大于7F的处理,请指教。
做了个TCP侦听的程序,当获取数据后,对数据进行一个字一个字的读取,然后转换成十六进制,发现,当大于7F时,进来的就是FFFD,而不是80,并且总是在此处出错,请高手指教。相关代码如下:Dim a As String = ""
While Listening '循环获取数据
If isConnected = True Then
Try
Message = ""
Dim Reader As New StreamReader(tpClient.GetStream())
While Reader.Peek() >= 0
a = Hex(Reader.Read())
Message = Message & Microsoft.VisualBasic.Right("00" & a, 2) & " "
End While
Message = Trim(Message)
If Len(Message) > 2 Then
showMessage = Message
Me.demoThread = New Thread(New ThreadStart(AddressOf Me.ThreadProcSafe))
Me.demoThread.Start()
End If
Catch ex As Exception
isConnected = False
Thread.CurrentThread.Abort()
'MsgBox("连接错误。")
End Try
End If
End While
怎么样才能处理大于7F的数据,谢谢了!!