Index: internals.hpp =================================================================== --- internals.hpp (revision 83084) +++ internals.hpp (working copy) @@ -104,6 +104,15 @@ template void stream_format_state:: apply_on (basic_ios & os, boost::io::detail::locale_t * loc_default) const { + // If a locale is available, set it first. "os.fill(fill_);" may chrash otherwise. +#if !defined(BOOST_NO_STD_LOCALE) + if(loc_) + os.imbue(loc_.get()); + else if(loc_default) + os.imbue(*loc_default); +#else + (void) loc_default; // keep compiler quiet if we don't support locales +#endif // set the state of this stream according to our params if(width_ != -1) os.width(width_); @@ -114,14 +123,6 @@ os.flags(flags_); os.clear(rdstate_); os.exceptions(exceptions_); -#if !defined(BOOST_NO_STD_LOCALE) - if(loc_) - os.imbue(loc_.get()); - else if(loc_default) - os.imbue(*loc_default); -#else - (void) loc_default; // keep compiler quiet if we don't support locales -#endif } template