Am Donnerstag, 26. Oktober 2006 18:05 schrieb Jean-Marc Lasgouttes:

> Can't we just change the encoding of the output stream on the fly
> (with a method, not only in the constructor)?

That was my first idea, but it turned out to be rather difficult. Here is 
how I came to the current solution:

codecvt facets are only used by file streams -> OK, maybe we could use file 
streams and not generic streams in the latex() methods? No, that does not 
work, we use them at several places to write to string streams.
Next try: Maybe we could do something else than codecvt in our streams, and 
add a setEncoding() method? That does not work unless we rebuild the 
functionality of file and string streams, since both odocfstream and 
odocstringstream inherit from std::basic_ostream<docstring> and we can 
neither add a method to that class nor change the inheritance of the file 
and string streams.

What might be possible is to encapsulate the real file and string streams 
in our own version, and use a homemade streambuf that would do the 
encoding conversion and then forward to the real stream. That would 
probably work, but would require far more code and a good understanding of 
stream buffers to get it right. I simply don't have the time at the moment 
to investigate this, and what I implemented works.
If somebody does not like it because it is a hack then feel free to do it 
correctly.


Georg

Reply via email to