Your code is correct! It were my wrong editor settings, after enabling autodetection of UTF8 it looks correct, see png.
But there are warnings when compiling with msvc: stream6.cpp(252) : warning C4244: 'return' : conversion from 'ascii_ctype_facet::char_type' to 'char', possible loss of data stream6.cpp(253) : warning C4244: 'argument' : conversion from 'ascii_ctype_facet::char_type' to 'wint_t', possible loss of data stream6.cpp(261) : warning C4244: '=' : conversion from 'const ascii_ctype_facet::char_type' to 'char', possible loss of data stream6.cpp(263) : warning C4244: 'argument' : conversion from 'const ascii_ctype_facet::char_type' to 'wint_t', possible loss of data when the casts are correct, why add explicit casts. -- Peter Kümmel