Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

UTF8.GetString new behavior in .NET Framework 4.0

$
0
0

private static string ByteArrayToString(byte[] characters)
        {
            string constructedString = Encoding.UTF8.GetString(characters);
            constructedString = constructedString.Trim();
            MessageBox.Show(((int)constructedString[0]).ToString() + " '" + constructedString.Substring(0, 3) + "'");
            return (constructedString);
        }

The byte array does contain the Byte-Order-Marker, and the data is an XML.
In 3.5, the message box displays 60 '<?&' --- 60 is the ascii value of <
In 4.0, the message box displays 65279 '<?' --- 65279 is the ascii value of Zero Width No Brake Space

Is this expected?


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>