I have some troubles with using boost::locale (1.49) on Debian 7 GNU/Linux (version of GCC is 4.6.3-1). The code is saved in cp1251. Using functions like "isalpha" (or "boost::algorithm::is_alpha") ends up with exception (bad_cast). Looks like that there's no proper facet for this check. Here's the code:
#include <iostream>
#include <boost/locale.hpp>
int main ()
{
boost::locale::generator gen;
std::locale loc(gen.generate("ru_RU.cp1251"));
unsigned char debug501 = 'Б';
bool debug500 = std::isalpha(debug501, loc);
std::cout<< debug500;
return 0;
}
It runs with no exception on Windows 7 with Visual Studio 2008. However, there's still one trouble: "debug500" is set to false in this case. It works fine only when locale is generated like this: std::locale loc(".1251")
. But the same issue appears when locale is generated by boost: std::locale loc(boost::locale::generator().generate("ru_RU.cp1251"));
.
I would be thankful if someone could explain what's wrong with the code and/or how I can make a similar check (isalpha) using boost and std with cp1251 locale.
Replace:
unsigned char debug501 = 'Б';
with:
char debug501 = 'Б';