I have a function that can decode an array of bytes into a string of characters using the specified encoding.
Example:
Function Decode(ByVal bytes() As Byte, ByVal codePage As String) As String Dim enc As Text.Encoding = Text.Encoding.GetEncoding(codePage) Return enc.GetString(bytes) End Function
If I want to include base64 in this, I should do something like this:
Function Decode(ByVal bytes() As Byte, ByVal codePage As String) As String If String.Compare(codePage, "base64", True) = 0 Then Return Convert.ToBase64String(bytes) Else Dim enc As Text.Encoding = Text.Encoding.GetEncoding(codePage) Return enc.GetString(bytes) End If End Function
Why is base64 handled in a special way in .NET?
source share