[Locale] as::ftime formatting
Hey, docs say: "There is a list of supported strftime flags by ICU backend:". I didn't build my boost/locale with ICU but still tried what happens when I try as::ftime("%A") an to my surprise I got correctly localized day of the week. My questions are: is it correct that it works without ICU? will it work on other machines (Win 32 bit)? What is the encoding of output string? I am seeing it correctly displayed as utf-8 but would like to know what is happening. Can I ensure utf-8 output? My test code: using namespace boost::locale; generator gen; locale loc=gen(""); std::ostringstream ostr; ostr.imbue(loc); ostr << as::datetime << as::ftime("%A") << info.time; std::String timeStr = ostr.str(); Cheers, Simon -- Szymon Gatner The Lordz Games Studio www.thelordzgamesstudio.com
----- Original Message -----
From: Szymon Gatner
To: boost-users Cc: Sent: Wednesday, January 9, 2013 3:29 PM Subject: [Boost-users] [Locale] as::ftime formatting Hey,
docs say: "There is a list of supported strftime flags by ICU backend:". I didn't build my boost/locale with ICU but still tried what happens when I try as::ftime("%A") an to my surprise I got correctly localized day of the week.
It uses general format of strftime familiy of functions. The supported flags depend on actual backend. - For "posix" and "std" backeds these are native flags and depend on implementation. - For ICU these flags are not-native and are translated to ICU specific ones (see the list) - For winapi they are transated as well and have different tags set, in general all but '%j' are supported. Full list can be found there: https://svn.boost.org/svn/boost/trunk/libs/locale/src/win32/api.hpp
My questions are: is it correct that it works without ICU?
Yes
will it work on other machines (Win 32 bit)?
If you use winapi or std backends some locales may be not installed. So if you use Chinese locales and they are not installed they may not work.
What is the encoding of output string? I am seeing it correctly displayed as utf-8 but would like to know what is happening. Can I ensure utf-8 output?
Yes, it happens because Boost.Locale uses Wide API under Windows to get Unicode characters
My test code:
using namespace boost::locale;
generator gen; locale loc=gen("");
std::ostringstream ostr; ostr.imbue(loc); ostr << as::datetime << as::ftime("%A") << info.time; std::String timeStr = ostr.str();
Cheers, Simon
-- Szymon Gatner The Lordz Games Studio www.thelordzgamesstudio.com
Regards, Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/
participants (2)
-
Artyom Beilis
-
Szymon Gatner