Re: [boost] [Locale] translate() couples key and output character widths

That was a loooooong and painful discussion during the boost.locale review. Such a change was asked by the reviewers that wanted to be able to use wide strings as keys. For example translate(L"© All Rights Are Reserved") Where "©" is non-ASCII character. This change was mostly required to support non-ascii characters in keys. To be honest I was strongly against the change but finally had to accept it. See: http://thread.gmane.org/gmane.comp.lib.boost.devel/218543 Also you can search boost lists the locale review comments... Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ -------------------------------------------- On Fri, 12/20/13, Alexander Lamaison <awl03@doc.ic.ac.uk> wrote: Subject: [boost] [Locale] translate() couples key and output character widths To: boost@lists.boost.org Date: Friday, December 20, 2013, 1:01 PM I've finally gotten round to changing from the pre-release version of Boost.Locale (v2.92) to the version now in Boost, and I was quite surprised by one change. Previously, I could do the following: void function_takes_wide_string(std::wstring message); function_takes_wide_string(boost::locale::translate("My translation key")); However, with the new version, the key must be passed in as a wide string if I am to be able to get a wide string out. This means changing `translate("blah")` to `translate(L"blah")` throughout. The change itself is no big deal, but the problem is that it feels like a change for the worse. The character width of the key is now coupled to the character width of the output, when the two are separate concepts and should be allowed to vary independently. The old class `message` coeerced the string to whichever width was required. The new class `basic_message<T>` coerces only to `basic_string<T>` and, worse than that, doesn't provide a method to explicitly convert to a different width string. My question, I suppose, is why was this change made? What makes the new API better? Alex -- Swish - Easy SFTP for Windows Explorer (http://www.swish-sftp.org) _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Artyom Beilis <artyomtnk@yahoo.com> writes:
That was a loooooong and painful discussion during the boost.locale review.
Such a change was asked by the reviewers that wanted to be able to use wide strings as keys. For example
translate(L"© All Rights Are Reserved")
Where "©" is non-ASCII character.
This change was mostly required to support non-ascii characters in keys. To be honest I was strongly against the change but finally had to accept it.
See: http://thread.gmane.org/gmane.comp.lib.boost.devel/218543
Also you can search boost lists the locale review comments...
I remember the discussion and I understand why `message` was templated to allow wchar_t keys. But what I don't understand is why the templated `basic_message` lost one of its coersion (conversion) methods in the process? In other words, why these don't work: std::wstring(boost::locale::basic_message<char>("blah")); std::string(boost::locale::basic_message<wchar_t>(L"wideblah")); Alex -- Swish - Easy SFTP for Windows Explorer (http://www.swish-sftp.org)
participants (2)
-
Alexander Lamaison
-
Artyom Beilis