I'm passing this string to a report: Economia e Administração
But the report displays the following: Economia e Administração
In the URL it gets encoded as:
Economia%20e%20Ad开发者_Go百科ministra%C3%83%C2%83%C3%82%C2%A7%C3%83%C2%83%C3%82%C2%A3o%20
I tried using URLDecode, but it doesn't work.
Any ideas?
Thanks!
It looks like it's being converted into UTF-8 twice, ie, an encoded string is being encoded again. Is the original string being passed as Unicode or UTF-8 or something else?
CORRECTION: it's converted into UTF-8 three times!
Here's my solution...In parent report convert the string to a Byte array string and pass that to the child report:
Function GetStringBytes(ByVal theString As String) As String
Dim bytes() As Byte = System.Text.Encoding.UTF8.GetBytes(theString, 0, theString.Length)
Dim builder As New System.Text.StringBuilder
For Each i As Integer In bytes
builder.Append(i & "|")
Next i
Return builder.ToString().TrimEnd("|")
End Function
In the Child report pass the byte array string to the GetString function below to convert it back to the original string:
Function GetString(ByVal theBytes As String) As String
Dim byts() As Byte = New Byte(theBytes.Split("|").Length) {}
Dim count As Integer = 0
For Each i As String In theBytes.Split("|")
byts(count) = Convert.ToInt32(i)
count += 1
Next i
Return UTF8ByteArrayToString(byts)
End Function
Function UTF8ByteArrayToString(ByVal theChars As Byte()) As String
Dim aEncoding As System.Text.UTF8Encoding = New System.Text.UTF8Encoding()
Dim aConstructedString As String = aEncoding.GetString(theChars)
Return aConstructedString
End Function
Works perfect for me.
精彩评论