MA said:
I have a major problem. I need to write an textfile with 1 b per letter.
But
it should be able to handle swedish letters to (åäö).
Is it possible to use 8 b ASCII for this?
There's no such thing as "8 bit ASCII" (assuming that's what you meant
by "b").
This file is used by an sms application and cannot be in another
format.
You need to find out *exactly* what encoding will be used. There are
various 8 bit character sets which are compatible with ASCII in the
range 0-127, but which are incompatible with each other above 127. If
you can find out which of those your app needs to output, it should be
easy to find the appropriate Encoding to give to your StreamWriter.
--
Jon Skeet - <
[email protected]>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Ok. Is it ASCII-8 then?
Well, I solved it by using this code:
char[] test = mailContent.ToCharArray();
System.Text.Encoding enc = System.Text.Encoding.GetEncoding("437");
System.Text.Encoder ence = enc.GetEncoder();
FileStream fsWriter = new FileStream(filePath + fileName,
System.IO.FileMode.Create);
byte[] bytes = new Byte[ence.GetByteCount(test,0, test.Length, true)];
ence.GetBytes(test, 0, test.Length, bytes, 0, true);
fsWriter.Write(bytes, 0, bytes.Length);
/Marre