I have a problem converting a binary array of data to string. When i convert the bytearray to string i dont get the right string. I have tried one miljon ways to convert the bytearray to char.
Without success.
When i connects from my NT4 to my XP computer. Sending the string "åäö", it works fine!. But when i connect to myself (XP-XP) and sends "åäö" i just receive "???" Or " controle chars.
Can somone explain to me why the hell! NT4 can send Ascii string in the right way. And XP cant.
All this using Telnet.exe to .NET Socket. The incoming byte array are diffrent when receiving from NT and XP.
This is the function iam using..
Code:Private Sub BuildString(ByVal Bytes() As Byte, ByVal offset As Integer, ByVal count As Integer) Try Dim intIndex As Integer Dim txt As String Dim lByte() As Byte Dim Uni As New UTF8Encoding 'Uni = Uni.GetEncoding(1252) m_State = StateStatus.sckReceiving 'Set state 'For intIndex = offset To offset + count - 1 'txt = txt + Convert.ToChar(Bytes(intIndex)) txt = txt + Uni.GetString(Bytes) 'Next RaiseEvent DataReceived(Me, txt.ToString, txt.Length) 'Raise event m_State = StateStatus.sckConnected 'Set state Catch ex As ExceptionHandler ' Sub level exception handling Throw New ExceptionHandler("Error occured.", ex) Catch ex As Exception ' Sub level exception handling Throw New ExceptionHandler("Error occured.", ex) End Try End Sub




Reply With Quote