Issue with Base64Encoding for Unicode Data

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • amollokhande1
    New Member
    • Feb 2008
    • 33

    Issue with Base64Encoding for Unicode Data

    Hi All,

    Currently we are facing an issue while decoding the Base64Encoded unicode data.

    Here is the scenario

    We have one custom javascript function that encodes the unicode data using Base64 mechanism. After encoding the data on client side we are sending it back to the server. On Server side we are decoding this unicode data using microsoft framework inbuild functions as below
    Code:
    Private Function DecodeVarHash(ByVal strEncoded As String) As string      
    Dim strDecoded As String = ""
    If strEncoded <> "" Then
    Dim enc As New System.Text.UTF8Encoding
    Try
    Dim Buffer As Byte() = Convert.FromBase64String(strEncoded)                        
    strDecoded = enc.GetString(Buffer)
    Catch ex As Exception
    End Try
    End If
    
     Return strDecoded
    
    End function
    But when we decode the unicode data using above function it return me some garbage data, i.e it is not properly returning me the original unicode data. For english data above function work properly, but for the data like Hindi, Chinese character it is not properly decoding the data.

    Can any body help me how to decode the client side unicode data properly on server side?

    Regards
    Amol Lokhande
Working...