Results 1 to 2 of 2

Thread: RESOLVED - [02/03] byte to character conversion issue

Threaded View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Minnesota
    Posts
    830

    Resolved RESOLVED - [02/03] byte to character conversion issue

    Taking a buffer and putting into a byte array and looping through each character (translating a few) and then outputing bytes. I am finding that certain bytes are not being converted properly.

    I am able to view the final result a different way by going through the website and can compare the output.

    Output from the code below:
    Code:
    ?py;£¢ã]?Ì$ñLPä0P	S??<âÓï.ï¾Ê²îüþ`f?gçË¿?
    Same line but from file from web:
    Code:
    ’py;£¢ã]‹Ì$ñLPä0P	S„€<âÓï.ï¾Ê²îüþ`fžgçË¿™
    You can see the first and last character is ? on my output but should be different. Is it something with converting back with chr()?

    My code producing output
    [Highlight=VB]
    Dim toBytes() As Byte = ASCIIEncoding.Default.GetBytes(FDXClientAPI.FedExAPITransaction(nRoute, Request.ToString(), IP, nPort))
    Dim backstrign = ASCIIEncoding.Default.GetString(toBytes)

    Dim SByte As Byte
    Dim sTmp As String
    Dim iFound As Integer
    Dim iEnd As Integer
    Dim sTmpHolder As String
    Dim iEncoding As Integer
    Dim sOutput As String
    Dim objWriter As StreamWriter
    Dim ErrInfo As String
    objWriter = New StreamWriter("C:\Output.pdf")

    Try
    For Each SByte In toBytes

    sTmp = Chr(SByte)

    Select Case SByte
    Case 37
    iFound = 1
    iEncoding += 1
    Case 34
    If iFound = 1 Then
    Exit For
    End If
    End Select

    If iFound = 1 Then
    If iEncoding > 0 Then
    sTmpHolder &= sTmp
    If sTmpHolder.Length = 3 Then
    Select Case sTmpHolder
    Case "%25"
    objWriter.Write("%")
    Case "%00"
    objWriter.Write(vbNullChar)
    Case "%22"
    objWriter.Write("""")
    End Select
    iEncoding = 0
    sTmpHolder = String.Empty
    End If
    Else
    objWriter.Write(sTmp)
    End If
    End If
    Next

    Catch Ex As Exception
    ErrInfo = Ex.Message
    End Try

    objWriter.Close()

    txtOutput.Text = backstrign
    [Highlight=VB]
    Last edited by lleemon; Aug 4th, 2006 at 11:12 AM. Reason: Resolved

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