Re: Unicode textwriter
 
"Ole Nielsby" wrote:
What's the best way, in unmanaged code, to write
unicode streams?
It can depend on ypur needs. Standard streams can be used as 
generic mechanism. However, if you need something special, 
standard stream can be less convenient solution than custom 
IO.
My objects will have ToStream(xTextWriter *output)
methods that write a unicode representation of themselves
to an abstract stream object that might write the text to
a file or build a string from it (or simply do a count).
In .NET, a TextWriter would be the obvious thing to
use, but I need an unmanaged equivalent.
Should I pass an ostream and always use wide formatting
functions, or should I wrap the ostream and define
<< operators for it, or is this wrapping already at hand,
or is there some other method I have overlooked?
No, there are wide counterparts for wide streams. You can 
distinguish them by `w' prefix. Wide character stream is 
`std::wostream'.
Sorry if have missed some obvious answers, my C++
experience is limited. It looks to me like the standard
libraries are byte oriented and not really in tune for
unicode.
As I pointed above, all standard streams have wide character 
typedef's provided by the library. So, all you need to do is 
to create a stream object (file-based, string-based, or 
whatever) and output text with it. If binary accuracy is of 
any importance for you, then beware of text conversions made 
by text streams (e.g., '\n' will become '\r''\n' under 
Windows). You can set text or binary mode explicitly, too. 
That's all.
HTH
Alex