Fix bad_cast exception thrown from boost::locale::conv::*.