Results 1 to 2 of 2

Thread: Sending socket strings between XP and NT4 dosent work!

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2002
    Posts
    23

    Unhappy Sending socket strings between XP and NT4 dosent work!

    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

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Apr 2002
    Posts
    23

    My solution...

    The encoding class dosent support ASCII 8 bit and above..

    Therefor i used the "OLD" visualbasic function "Convert"

    This is the solution....

    Code:
      For i = 0 To Bytes.Length - 1
                        txt = txt & Convert.ToChar(Bytes(i))
                    Next

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width