decode base64 string

Discussion in 'ASP .Net' started by Guoqi Zheng, Sep 26, 2004.

  1. Guoqi Zheng

    Guoqi Zheng Guest

    Hi,

    Any one has a code example of how to decode base64 string?


    I used below function but it does not work correctly, especially when I need
    to decode some Characters like Chinese,

    Can some one give an example or point out what I did wrong here? Thanks.


    Public Function DecodeBase64(ByVal strInput As String) As String

    Dim ReturnByte As Byte()

    ReturnByte = System.Convert.FromBase64String(strInput)

    Dim ReturnString As String

    ReturnString = System.Text.Encoding.UTF8.GetString(ReturnByte)

    Return ReturnString

    End Function
    Guoqi Zheng, Sep 26, 2004
    #1
    1. Advertising

  2. UTF8 might not work for high bit character sets like Chines. You'll want to
    use Unicode encoding or the specific code page for the language in question.

    +++ Rick ---

    --

    Rick Strahl
    West Wind Technologies
    http://www.west-wind.com/
    http://www.west-wind.com/weblog/
    http://www.west-wind.com/wwThreads/
    ----------------------------------
    Making waves on the Web


    "Guoqi Zheng" <> wrote in message
    news:OhgCgY$...
    > Hi,
    >
    > Any one has a code example of how to decode base64 string?
    >
    >
    > I used below function but it does not work correctly, especially when I

    need
    > to decode some Characters like Chinese,
    >
    > Can some one give an example or point out what I did wrong here? Thanks.
    >
    >
    > Public Function DecodeBase64(ByVal strInput As String) As String
    >
    > Dim ReturnByte As Byte()
    >
    > ReturnByte = System.Convert.FromBase64String(strInput)
    >
    > Dim ReturnString As String
    >
    > ReturnString = System.Text.Encoding.UTF8.GetString(ReturnByte)
    >
    > Return ReturnString
    >
    > End Function
    >
    >
    Rick Strahl [MVP], Sep 27, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?QmVnaW5uZXI=?=

    Decode a PNG image from Base64

    =?Utf-8?B?QmVnaW5uZXI=?=, Mar 9, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    807
    =?Utf-8?B?QmVnaW5uZXI=?=
    Mar 9, 2006
  2. Damir Hakimov

    base64.encode and decode not correct

    Damir Hakimov, Aug 16, 2005, in forum: Python
    Replies:
    1
    Views:
    348
  3. Replies:
    0
    Views:
    552
  4. Mr. T

    decode base64 encoded login info

    Mr. T, Mar 5, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    517
    Patrice
    Mar 5, 2007
  5. PerlFAQ Server

    FAQ 9.18 How do I decode a MIME/BASE64 string?

    PerlFAQ Server, Apr 7, 2011, in forum: Perl Misc
    Replies:
    0
    Views:
    180
    PerlFAQ Server
    Apr 7, 2011
Loading...

Share This Page