I get a ISO-8859-1-encoded string from an exernal DLL, and I must use it to create a link.
Apparently, in production (I have no access to the production server whatsoever), it adds "%00" at the end of the utf-8-decoded strings. I understand that it is a null-terminated string, then. How can I handle this situation ?
My conversion function is this one :
Private Function DecodeString(ByRef SourceData As String, ByVal SourceEncoding As Encoding, ByVal OutputEncoding As Encoding) As String
Dim bSourceData As Byte() = SourceEncoding.GetBytes(SourceData)
Dim bOutData As Byte() = System.Text.Encoding.Convert(SourceEncoding, OutputEncoding, bSourceData)
Return OutputEncoding.GetString(bOutData)
End Function
What do I have to change to make it work ? I thought of something like .Replace("%00", "")
but even if it worked, I don't think it would solve the underlying problem...
I found this : Fastest way to convert a possibly-null-terminated ascii byte[] to a string? but I don't want to do it "in the fastest way possible", and I don't like the "unsafe" part, as it is for a banking site (even if I don't understand exactly what it can lead to, I don't want to take any unnecessary risk).
Thanks