i’m on vb .net (2005 & 2010), and have an undesired output when writting ascii chars to a file.
On the debug console, i get (chr(128, chr(147), chr(130)):
€
“
‚
On the file, i get:
€
â€
‚
It some kind of rubbish? y need to delete them, the line MUST start with € and the others.
I’m System.IO.StreamWriter and it’s .WriteLine method, with and without flushing.
Thanks!
Well,
StreamWriteruses UTF-8 as the encoding unless you specify anything else.It’s not at all clear what you’re using to read the file – but if you can make it read the file as UTF-8, it may well show what you were expecting.
Personally I would avoid using
Chr, favouring the more portableChrWwhich doesn’t rely on the current thread’s settings for the default encoding.Now, as to what the file ought to contain – it really depends on what’s going to read it. I generally think UTF-8 is a good encoding to use, but it’s clearly not the one you were expecting…