Help to Convert ASCII to UTF-8 - Should be Simple

how can i convert like "A!" to " "
and like "
Uc" to " "


And so on.. Its like turning it into ascii instead of what its supposed to be



Answer this question

Help to Convert ASCII to UTF-8 - Should be Simple

  • Carl Tawn

     

    Right. You come in with a string of variable length and it's going to create a variable number of bytes with an array. Then the byte buffer of variable length is converted into a variable length string.

    Those routines are sort of randon character generators. 

    "Im saying i need to encode it back to utf8"

    It was never utf8 to begin with.



  • Rodboy

    its a string that needs to be converted to utf-8


  • seamus.glynn

    OK.... I'm looking at the bits.

    Are you saying that the display is not displaying the data correctly



  • JockePe

    nvm i found the answer.

    Public Function utf8_decode(ByVal indata As String) As String
    Dim buffer() As Byte = Encoding.UTF8.GetBytes(indata)
    Return Encoding.Default.GetString(buffer)
    End Function

    Public Function utf8_encode(ByVal indata As String) As String
    Dim buffer() As Byte = Encoding.Default.GetBytes(indata)
    Return Encoding.UTF8.GetString(buffer)
    End Function

  • JEP

    Input is a String, Output a string.

    Im trying to add it to a listview


  • vkumar

    nvm i found the answer.

    Public Function utf8_decode(ByVal indata As String) As String
    Dim buffer() As Byte = Encoding.UTF8.GetBytes(indata)
    Return Encoding.Default.GetString(buffer)
    End Function

    Public Function utf8_encode(ByVal indata As String) As String
    Dim buffer() As Byte = Encoding.Default.GetBytes(indata)
    Return Encoding.UTF8.GetString(buffer)
    End Function


  • marguslapp

    What's your datatype



  • dksimon

    No
    Im saying i need to encode it back to utf8


  • rschnell

     

    OK !!! Now we're getting somewhere.......

    For a moment let's talk about three things. The inputs, outputs and your display.

    What is the input and the input datatype   What is the output and the output datatype What are your display needs In your words, that determines what it's supposed to be

    Information about your architecture is needed.

     



  • Shiku

    None of those characters are ascii.

    "Uc" this is two unicode characters.

    This is one. I guess what isn't clear is your requirements.

  • Help to Convert ASCII to UTF-8 - Should be Simple