Topic: streams for unicode files?


Author: "James Kuyper Jr." <kuyper@wizard.net>
Date: Sat, 24 Nov 2001 01:53:37 GMT
Raw View
Alex Kro wrote:
>
> Hello,
>
> What level of support does the standard provide for operating with UNICODE
> files?  Can streams be used for this purpose?

The standard provides a few, inadequate, hooks that an implementor can
use to support Unicdoe, but it's entire up to the implementor whether or
not they actually use them that way.
If the implementor does not make that choice, there's nothing you can do
using standard functions. You can write your own, or use a third-party
unicode library.

The way for an implementor to do this is to choose to have either char
or wchar_t use Unicode encodings. If they made that choice, all you have
to do is open a standard fstream or wfstream, respectively (you may have
to set the appropriate locale for some purposes, which may or may not be
the default locale).

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: "Alex Kro" <res0m4rf.spammersnot@net.verizon>
Date: Wed, 21 Nov 2001 18:16:53 GMT
Raw View
Hello,

What level of support does the standard provide for operating with UNICODE
files?  Can streams be used for this purpose?

I hoped for basic_filebuf<wchar_t>, but it doesn't seem to be of any help.
It can produce wchar_t output, but still it treats files as consisting of
char's.  Although basic_filebuf<wchar_t> seem to know how to convert single
byte characters to wchar_t depending on the current locale.

It would be desirable to have a stream buffer that can properly read and
write UNICODE files.  There are several encodings in the unicode family
(like UNICODE, UNICODE big endian, UTF-7, UTF-8, UTF-16) and each encoding
is identified by the prefix a file begins with.

Many contemporary frameworks (not necessarily C++) provide some kind of
support in this area.  There even may be third party libraries compatible
with standard streams that support UNICODE (if there are, I definitely want
to know about them).  Is C++ standard also moving in this direction?

Thanks,
Alex Kro.


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]