我将此字符串传递给报告:Economia e Administração
但报告显示以下内容:Economia e Administração
在URL中,它被编码为:
Economia%20e%20Administra%C3%83%C2%83%C3%82%C2%A7%C3%83%C2%83%C3%82%C2%A3o%20
我尝试使用URLDecode,但它不起作用。
有什么想法吗?
谢谢!
答案 0 :(得分:0)
看起来它被转换为UTF-8两次,即,编码的字符串再次被编码。原始字符串是以Unicode还是UTF-8或其他方式传递的?
更正:它被转换为UTF-8三次!
答案 1 :(得分:0)
这是我的解决方案......在父报告中将字符串转换为字节数组字符串并将其传递给子报告:
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
在Child报告中,将字节数组字符串传递给下面的GetString函数,将其转换回原始字符串:
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
适合我的作品。