2012/7/10 Artyom Beilis <artyomtnk@yahoo.com>
The locale name should be "en_US.UTF-8" or "ru_RU.UTF-8", the default UTF-8 locale is for
default system locale "".

When you set locale as "en" it assumes that encoding (as not specified) is US-ASCII and conversion fails.
š
Artyom Beilis
--------------
CppCMS - C++ Web Framework:šš http://cppcms.com/
CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/


From: NtVisigoth <ntvisigoth@gmail.com>
To: boost-users@lists.boost.org
Sent: Tuesday, July 10, 2012 12:36 PM
Subject: [Boost-users] Boost 1.49 Locale Conversion failed

Hello, everyone!

But previous latter badly typed.

When using boost::locale with the russian language of the string in UTF-8 encoding I get an error while getting the locale.
An exception with the message e.what(): "Conversion failed" is thrown

My code is not very different from that in the examples:

#define šTR(S) šboost::locale::translate(S).str()
const std::string strDefaultLangId( "en" );
int main( int argc, char * argv[] )
{
š š using namespace std;
š š using namespace boost::locale;
š š int exitCode = EXIT_SUCCESS;
š š try
š š {
š š š š generator gen;
š š š š gen.add_messages_path("g:\\source\\boost_locale\\languages\\");
š š š š gen.add_messages_domain("messages");
š š š š std::string language( argc == 2 ? argv[1] : strDefaultLangId.c_str() );
š š š š std::locale loc = gen( language );
š š š š locale::global( loc );
š š š š std::wstring s = TR(L"hello world");
š š š š wcout << s << endl;
š š }
š š catch( exception& e )
š š {
š š š š cout << "Error : " << e.what() << endl;
š š š š exitCode = EXIT_FAILURE;
š š }
š š catch( ... )
š š {
š š š š cout << "Unknown error" << endl;
š š š š exitCode = EXIT_FAILURE;
š š }
š š return exitCode;
}


The path to the file with the russian language: "g:\source\boost_locale\languages\ru\LC_MESSAGES\messages.mo"

What could be wrong?
* Is it necessary to use the backends?
* Is it yet necessary to call imbue on the stream? But I'd like avoid it because I am going to write the log using glog.š

Compillers : Microsoft Visual Studio 2008 and 2010
Boost version : 1.49


_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users


_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

I have :
1) Russian language Filename : g:\project\proba\locale\ru_RU.UTF-8\LC_MESSAGES\messages.mo
2) Russian language locale name in σ++-source:
const šstd::string šruLanguage( "ru_RU" )

Is it correct?

I dont understand How Boost Locale finds languages MO-file by their locale names in C++-source.