Boost C++ Libraries: Ticket #859: boost::format ignores a user defined locale https://svn.boost.org/trac10/ticket/859 <pre class="wiki">Altough someone can supply a user locale to boost::format, it isn't recognized. const std::locale&amp; userLocale = getUserLocale(); boost::format formatter (formatString, userLocale); I could fix the problem in feed_args.hpp, function put, line 133 (boost 1.33.1): 133 basic_oaltstringstream&lt;Ch, Tr, Alloc&gt; oss( &amp;buf); + if (loc_p) + { + oss.imbue (*loc_p); + } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/859 Trac 1.4.3 Samuel Krempp Thu, 16 Aug 2007 19:39:53 GMT owner, status changed; severity set https://svn.boost.org/trac10/ticket/859#comment:1 https://svn.boost.org/trac10/ticket/859#comment:1 <ul> <li><strong>owner</strong> changed from <span class="trac-author">samuel_k</span> to <span class="trac-author">Samuel Krempp</span> </li> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">new</span> </li> <li><strong>severity</strong> → <span class="trac-field-new">Problem</span> </li> </ul> Ticket René Rivera Sat, 18 Aug 2007 14:34:35 GMT component, description changed https://svn.boost.org/trac10/ticket/859#comment:2 https://svn.boost.org/trac10/ticket/859#comment:2 <ul> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">format</span> </li> <li><strong>description</strong> modified (<a href="/trac10/ticket/859?action=diff&amp;version=2">diff</a>) </li> </ul> Ticket Samuel Krempp Sun, 15 Nov 2009 10:19:15 GMT status, resolution changed https://svn.boost.org/trac10/ticket/859#comment:3 https://svn.boost.org/trac10/ticket/859#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">invalid</span> </li> </ul> <p> Do you have a sample program exhibiting an issue ? </p> <p> The locale passed to boost::format constructor is not ignored, it is passed as "default" locale (i.e. last argument) to the put function by distribute : put&lt;Ch, Tr, Alloc, T&gt; (x, self.items_[i], self.items_[i].res_, self.buf_, boost::get_pointer(self.loc_) ); </p> <p> The put function itself relies on format_item's apply_on function to apply item's format state+locale (which will be self.loc_ unless an item's own locale was set in some way). </p> <p> I will take a deeper look into format's locale handling - there is surely room for improvement here and there, and at least add a paragraph to the documentation with simple examples. </p> <p> But user-defined locales are not "ignored", so closing the ticket as "invalid" unless sample complete program is supplied. </p> Ticket anonymous Tue, 15 May 2012 02:40:53 GMT status changed; resolution deleted https://svn.boost.org/trac10/ticket/859#comment:4 https://svn.boost.org/trac10/ticket/859#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">invalid</span> </li> </ul> <p> problem here isn't that locale is ignored problem that method os.fill that tries to use facet before imbue to the stream see actor for the stream_format_state </p> <blockquote> <p> if(width_ != -1) </p> <blockquote> <p> os.width(width_); </p> </blockquote> <p> if(precision_ != -1) </p> <blockquote> <p> os.precision(precision_); </p> </blockquote> <p> if(fill_ != 0) </p> <blockquote> <p> os.fill(fill_); </p> </blockquote> <p> os.flags(flags_); os.clear(rdstate_); os.exceptions(exceptions_); </p> </blockquote> <p> #if !defined(BOOST_NO_STD_LOCALE) </p> <blockquote> <p> if(loc_) </p> <blockquote> <p> os.imbue(loc_.get()); </p> </blockquote> <p> else if(loc_default) </p> <blockquote> <p> os.imbue(*loc_default); </p> </blockquote> </blockquote> <p> #else </p> <blockquote> <p> (void) loc_default; <em> keep compiler quiet if we don't support locales </em></p> </blockquote> <p> #endif </p> <p> imbue should be at very beginning of the actor, not at the very end </p> Ticket dmarkman@… Tue, 15 May 2012 02:43:37 GMT <link>https://svn.boost.org/trac10/ticket/859#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/859#comment:5</guid> <description> <p> we're getting segv for using boost::basic_format&lt;char16_t&gt; with appropriate locale with all appropriate facets because method os.fill uses std::ctype&lt;char16_t&gt; facet that wasn't ready </p> </description> <category>Ticket</category> </item> <item> <author>Jonathan Jones <jonathan.jones@…></author> <pubDate>Wed, 01 Aug 2012 20:03:59 GMT</pubDate> <title>cc set https://svn.boost.org/trac10/ticket/859#comment:6 https://svn.boost.org/trac10/ticket/859#comment:6 <ul> <li><strong>cc</strong> <span class="trac-author">jonathan.jones@…</span> added </li> </ul> Ticket Chris Newbold Mon, 10 Sep 2012 16:47:28 GMT <link>https://svn.boost.org/trac10/ticket/859#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/859#comment:7</guid> <description> <p> We've applied the following patch locally, which appears to resolve the issues described above: </p> <pre class="wiki">==== boost/boost/format/internals.hpp#4 (text) ==== *************** *** 105,110 **** --- 105,118 ---- void stream_format_state&lt;Ch,Tr&gt;:: apply_on (basic_ios &amp; os, boost::io::detail::locale_t * loc_default) const { // set the state of this stream according to our params + #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 if(width_ != -1) os.width(width_); if(precision_ != -1) *************** *** 114,127 **** 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&lt;class Ch, class Tr&gt; --- 122,127 ---- </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>James E. King, III</dc:creator> <pubDate>Wed, 11 Oct 2017 18:19:59 GMT</pubDate> <title>owner, status, version changed https://svn.boost.org/trac10/ticket/859#comment:8 https://svn.boost.org/trac10/ticket/859#comment:8 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Samuel Krempp</span> to <span class="trac-author">James E. King, III</span> </li> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">new</span> </li> <li><strong>version</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">Boost 1.34.0</span> </li> </ul> Ticket James E. King, III Wed, 11 Oct 2017 18:22:44 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/859#comment:9 https://svn.boost.org/trac10/ticket/859#comment:9 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> This patch is present since 1.56.0. </p> Ticket