none
how to decode =?windows-874?B?t7TKzbogdGVzdCB=?= to Thai Langauge ? RRS feed

  • Question

  • Dim TCP As Net.Sockets.TcpClient
    Dim POP3Stream As System.IO.Stream
    Dim inStream As System.IO.StreamReader

    TCP = New Net.Sockets.TcpClient
    TCP.Connect(strServer, 110)

    POP3Stream = TCP.GetStream
    inStream = New System.IO.StreamReader(POP3Stream, System.Text.Encoding.GetEncoding("utf-8"))

    strTemp = inStream.ReadLine

    While (strTemp <> ".")
    strEmailMess = strEmailMess & strTemp & vbCrLf
    strTemp = inStream.ReadLine
    End While


    For example: if strTemp is =?windows-874?B?t7TKzbogdGVzdCB=?=

    i have to cut ?windows-874?B? and ?= so, it will remains t7TKzbogdGVzdCB=

    and i will use code below to encode it to Thai letter

    Dim encoding As New System.Text.UTF8Encoding
    Dim Buffer As Byte() = Convert.FromBase64String(t7TKzbogdGVzdCB=)

    DecodeBase64 = encoding.GetString(Buffer)

    it's read ?????????


    How to make it read in Thai letter ?


    Any idea in C#?

    Thanks

    • Moved by Harry Zhu Monday, December 28, 2009 8:35 AM I'm moving the thread using vb.net (From:Visual C# General)
    • Moved by Jeff Shan Tuesday, December 29, 2009 3:43 AM c# question (From:Visual Basic General)
    Friday, December 25, 2009 6:43 AM

Answers

  • Hi,

    The above code can be changed into c# :

                byte[] Buffer = Convert.FromBase64String("t7TKzbogdGVzdCB=");
                System.Text.UTF8Encoding encoding =new System.Text.UTF8Encoding();
                string DecodeBase64 = encoding.GetString(Buffer);

    The result is :"���ͺ test ".
    It appears the encoded bytes are not right.
    Could you tell us where do you get the strTemp?

    Please note the UTF8Encoding is one kind of encoding for unicode which can present all languages including Thai .

    For more info about UTF-8 encoding , please take a look at the article:
    http://en.wikipedia.org/wiki/UTF-8

    Hope it will help,
    Harry


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Proposed as answer by Harry Zhu Thursday, December 31, 2009 2:09 AM
    • Marked as answer by Harry Zhu Saturday, January 2, 2010 3:06 AM
    Wednesday, December 30, 2009 2:49 AM