C
C# Learner
I'm trying to convert a UTF8 string to an ASCII string, but the code
I've tried isn't working.
<code>
private static string Utf8ToAscii(string value)
{
byte[] utf8Bytes = Encoding.UTF8.GetBytes(value);
byte[] asciiBytes = Encoding.Convert(Encoding.UTF8,
Encoding.ASCII, utf8Bytes);
return Encoding.ASCII.GetString(asciiBytes);
}
</code>
Am I doing something wrong?
TIA
I've tried isn't working.
<code>
private static string Utf8ToAscii(string value)
{
byte[] utf8Bytes = Encoding.UTF8.GetBytes(value);
byte[] asciiBytes = Encoding.Convert(Encoding.UTF8,
Encoding.ASCII, utf8Bytes);
return Encoding.ASCII.GetString(asciiBytes);
}
</code>
Am I doing something wrong?
TIA