Code pages

  • Thread starter Thread starter J M
  • Start date Start date
J

J M

Hi,

I'm working on a program that writes data to a DOS-file (a file that is to
be read by a DOS-program), thus using codepage 437.
When writing to a binary file there was no problem at all, I just used
GetEncoder(437) to write the byte arrays to the file.
But I also have to write to a sequential file. WriteLine doesn't support
byte arrays.
I ended up first encoding the strings to byte arrays, writing them to a
binary file, opening that binary file as a sequential file, reading the byte
arrays as strings again and then writing the records (containing a.o. those
strings) back to the sequential file I finally needed.

I hate this method. It takes way to long (I'm talking about over 20000
records)!

Is there any way that I can convert the unicode strings directly to codepage
437 and writing them to a sequential file????


Thanks in advance...



JF Mous
 
J M said:
Hi,

I'm working on a program that writes data to a DOS-file (a file that
is to be read by a DOS-program), thus using codepage 437.
When writing to a binary file there was no problem at all, I just
used GetEncoder(437) to write the byte arrays to the file.
But I also have to write to a sequential file. WriteLine doesn't
support byte arrays.
I ended up first encoding the strings to byte arrays, writing them to
a binary file, opening that binary file as a sequential file, reading
the byte arrays as strings again and then writing the records
(containing a.o. those strings) back to the sequential file I finally
needed.

I hate this method. It takes way to long (I'm talking about over
20000 records)!

Is there any way that I can convert the unicode strings directly to
codepage 437 and writing them to a sequential file????

Maybe I'm overlooking the problem, but when creating the Streamrwriter, you
can pass the Encoding object that you created before.


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
I've read the MSDN info on streamwriter (I'm not that familiar with it), but
its seems I can't create comma separated files with it...
The code I use now is like:

FileOpen(1, FileName, (...))
WriteLine(1, a string, another string, an integer, a double, a byte, .. etc)

The only streamwriter.writeline that accepts a paramarray wants a
formatstring first.
 
J M said:
I've read the MSDN info on streamwriter (I'm not that familiar with
it), but its seems I can't create comma separated files with it...
The code I use now is like:

FileOpen(1, FileName, (...))
WriteLine(1, a string, another string, an integer, a double, a byte,
.. etc)

The only streamwriter.writeline that accepts a paramarray wants a
formatstring first.

Right, but you can use it to write in the format you need.


sw.writeline ("{0}, {1}, {2}, {3}", a string, another string,....)


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
Back
Top