Connecting Tech Pros Worldwide Forums | Help | Site Map

Mixing Wide & Narrow Character Output to stdout

Andy
Guest
 
Posts: n/a
#1: Mar 15 '06
Can I mix wide and narrow character output to stdout? I seem to remember
hearing this was not supported before but I can't find any reference to
such a restriction now I actually need to do it! It seems to work on my
Intel compiler but is it portable?

e.g.

#include <iostream>
#include <iomanip>

int main()
{
std::cout << "Narrow ";
std::wcout << L"Wide\n";
return 0;
}
Dietmar Kuehl
Guest
 
Posts: n/a
#2: Mar 16 '06

re: Mixing Wide & Narrow Character Output to stdout


Andy wrote:[color=blue]
> Can I mix wide and narrow character output to stdout?[/color]

I don't think there is a specific restriction in the C++ standard
but there is one in C standard, if I remember correctly. Effectively,
there is a state machine underlying the C stream (and the C++ streams
are generally defined in terms of these) which does not allow directly
mixing narrow and wide characters (see
<http://www.dinkumware.com/manuals/reader.aspx?b=c/&h=lib_file.html>).
--
<mailto:dietmar_kuehl@yahoo.com> <http://www.dietmar-kuehl.de/>
<http://www.eai-systems.com> - Efficient Artificial Intelligence
Closed Thread