Abdelrazak Younes wrote:

> Georg Baum wrote:
>> No, that would not work for stringstreams for example. We use them a lot
>> to construct strings, and therefore we need a full ucs4 stringstream.
> 
> But ucs4 stringstream is an unrelated problem IMHO, the characters
> passing through the streams will be ucs4 and will stay like this.

No. If you output an ucs4 char to a std::ostream you will get its decimal
code point value. You will not just write the 4 bytes to the stream. Export
a file to LaTeX and look at all these numbers if you want to see what I
mean. If you output a ucs4 char to an ucs4 stream it will simply write the
four bytes to the stream and not convert them to decimal.

> There 
> is no need to do any conversion to utf8. So this is a different case
> from ostream which is char based anyway.
> 
>> And, what I forgot to tell: My first idea was to define a
>> 
>> operator<<(std::basic_ostream<lyx::char_type> &, char)
>> 
>> and do the widening in that operator, but that does not work, since the
>> std operator is preferred.
> 
> I don't understand... Why do you want to widen a char before outputting
> it? A char is a char and the default std::ostream is normally used as it
> should be.

A char is not a "character in the stream sense" if you want to output it to
a 4 byte wide stream.
Look e.g. at this code from insetnote.C:

        ostringstream ss;
        ss << "[";
        InsetText::plaintext(buf, ss, runparams);
        ss << "]";

Here you need to widen '[' and ']' if ss becomes an ucs4 stringstream. Here
"[" is used instead of '[', but the principle is the same.


Georg

Reply via email to