Connect with Expertise | Find Experts, Get Answers, Share Insights

Issue with Base64Encoding for Unicode Data

 
Join Date: Feb 2008
Posts: 33
#1: Dec 21 '09
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
Expand|Select|Wrap|Line Numbers
  1. Private Function DecodeVarHash(ByVal strEncoded As String) As string      
  2. Dim strDecoded As String = ""
  3. If strEncoded <> "" Then
  4. Dim enc As New System.Text.UTF8Encoding
  5. Try
  6. Dim Buffer As Byte() = Convert.FromBase64String(strEncoded)                        
  7. strDecoded = enc.GetString(Buffer)
  8. Catch ex As Exception
  9. End Try
  10. End If
  11.  
  12.  Return strDecoded
  13.  
  14. End function
  15.  
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

Reply