2 // Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
4 // Distributed under the Boost Software License, Version 1.0. (See
5 // accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
8 #define BOOST_LOCALE_SOURCE
10 #include <boost/cstdint.hpp>
11 #include <boost/locale/util.hpp>
12 #include "all_generator.hpp"
17 template<typename CharType>
18 std::locale codecvt_bychar( std::locale const &in,
19 std::string const &locale_name)
21 return std::locale(in,new std::codecvt_byname<CharType,char,std::mbstate_t>(locale_name.c_str()));
25 std::locale create_codecvt( std::locale const &in,
26 std::string const &locale_name,
27 character_facet_type type,
30 if(utf == utf8_from_wide) {
31 return util::create_codecvt(in,util::create_utf8_converter(),type);
35 return codecvt_bychar<char>(in,locale_name);
37 return codecvt_bychar<wchar_t>(in,locale_name);
38 #if defined(BOOST_HAS_CHAR16_T) && !defined(BOOST_NO_CHAR16_T_CODECVT)
40 return codecvt_bychar<char16_t>(in,locale_name);
42 #if defined(BOOST_HAS_CHAR32_T) && !defined(BOOST_NO_CHAR32_T_CODECVT)
44 return codecvt_bychar<char32_t>(in,locale_name);
55 // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4