Topic: Use of user defined code translation with wstring


Author: James Kanze <kanze@alex.gabi-soft.de>
Date: Mon, 6 May 2002 18:56:25 GMT
Raw View
According to 22.2.1.5/3 (concerning codecvt): "Instantiations on
mbstate_t perform conversion between encodings known to the library
implementor.  Other encodings can be converted by specializing on a
user-defined stateT type."

Which sounds very useful.  Except that if I understand things
correctly, classes like wstring, wistream, etc. are specialized on a
char_traits which defines the state_type to be mbstate_t.  Which means
that such user specializations imply a special string type, a special
istream type, etc.

So how is this really meant to be used?  In practice, I cannot simply
derive from codecvt_byname, since I know nothing of the type of
mbstate_t, and cannot use it to maintain any needed state.  But I
cannot create my own state type either, since in doing so, I can no
longer use wstring, wistream, etc.  (Obviously, the only utility of
creating my own multibyte conversions, as explained above, is to
dynamically imbue them in an wistream or an wostream.)

--=20
James Kanze                                mailto:kanze@gabi-soft.de
Conseils en informatique orient=E9e objet/
                    Beratung in objektorientierter Datenverarbeitung
Ziegelh=FCttenweg 17a, 60598 Frankfurt, Germany Tel. +49(0)179 2607481

---
[ 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.jamesd.demon.co.uk/csc/faq.html                       ]