How to read the unicode char? like "ä"
public static string Read(int length, string absolutePath)
{
StringBuilder resultAsString = new StringBuilder();
using (MemoryMappedFile memoryMappedFile = MemoryMappedFile.CreateFromFile(absolutePath))
using (MemoryMappedViewStream memoryMappedViewStream = memoryMappedFile.CreateViewStream(0, length))
{
for (int i = 0; i < length; i++)
{
int result = memoryMappedViewStream.ReadByte();
if (result == -1)
{
break;
}
char letter = (char)result;
resultAsString.Append(letter);
}
}
return resultAsString.ToString();
}
the read int (result) is 195 and the char cast gives me not the expected result.
Not sure if that's what you ask for, but, you can use StreamReader
StreamReader sr = new StreamReader(stream, Encoding.Unicode);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With