7 #ifndef BOOST_LOCALE_ENCODING_HPP_INCLUDED 8 #define BOOST_LOCALE_ENCODING_HPP_INCLUDED 10 #include <boost/locale/config.hpp> 11 #include <boost/locale/encoding_errors.hpp> 12 #include <boost/locale/encoding_utf.hpp> 13 #include <boost/locale/info.hpp> 14 #include <boost/locale/util/string.hpp> 17 # pragma warning(push) 18 # pragma warning(disable : 4275 4251 4231 4660) 21 namespace boost {
namespace locale {
30 template<
typename CharType>
31 std::basic_string<CharType>
35 template<
typename CharType>
36 std::string
from_utf(
const CharType* begin,
38 const std::string& charset,
45 template<
typename CharType>
46 std::basic_string<CharType>
49 return to_utf<CharType>(begin, end, std::use_facet<info>(loc).encoding(), how);
56 template<
typename CharType>
60 return from_utf(begin, end, std::use_facet<info>(loc).encoding(), how);
64 template<
typename CharType>
65 std::basic_string<CharType>
68 return to_utf<CharType>(text.c_str(), text.c_str() + text.size(), charset, how);
72 template<
typename CharType>
76 return from_utf(text.c_str(), text.c_str() + text.size(), charset, how);
80 template<
typename CharType>
81 std::basic_string<CharType>
84 return to_utf<CharType>(text,
util::str_end(text), charset, how);
88 template<
typename CharType>
97 template<
typename CharType>
98 std::basic_string<CharType>
101 return to_utf<CharType>(text.c_str(), text.c_str() + text.size(), loc, how);
107 template<
typename CharType>
111 return from_utf(text.c_str(), text.c_str() + text.size(), loc, how);
117 template<
typename CharType>
120 return to_utf<CharType>(text,
util::str_end(text), loc, how);
126 template<
typename CharType>
134 std::string
between(
const char* begin,
136 const std::string& to_encoding,
137 const std::string& from_encoding,
142 const std::string& to_encoding,
143 const std::string& from_encoding,
150 inline std::string
between(
const std::string& text,
151 const std::string& to_encoding,
152 const std::string& from_encoding,
156 text.c_str() + text.size(),
165 BOOST_LOCALE_DECL std::basic_string<char>
166 to_utf(
const char* begin,
const char* end,
const std::string& charset,
method_type how);
169 BOOST_LOCALE_DECL std::string
173 BOOST_LOCALE_DECL std::basic_string<wchar_t>
174 to_utf(
const char* begin,
const char* end,
const std::string& charset,
method_type how);
177 BOOST_LOCALE_DECL std::string
178 from_utf(
const wchar_t* begin,
const wchar_t* end,
const std::string& charset,
method_type how);
180 #ifdef BOOST_LOCALE_ENABLE_CHAR16_T 182 BOOST_LOCALE_DECL std::basic_string<char16_t>
183 to_utf(
const char* begin,
const char* end,
const std::string& charset,
method_type how);
186 BOOST_LOCALE_DECL std::string
187 from_utf(
const char16_t* begin,
const char16_t* end,
const std::string& charset,
method_type how);
190 #ifdef BOOST_LOCALE_ENABLE_CHAR32_T 192 BOOST_LOCALE_DECL std::basic_string<char32_t>
193 to_utf(
const char* begin,
const char* end,
const std::string& charset,
method_type how);
196 BOOST_LOCALE_DECL std::string
197 from_utf(
const char32_t* begin,
const char32_t* end,
const std::string& charset,
method_type how);
209 # pragma warning(pop) Default method - skip.
Definition: encoding_errors.hpp:44
std::string between(const char *begin, const char *end, const std::string &to_encoding, const std::string &from_encoding, method_type how=default_method)
Convert a text in range [begin,end) to to_encoding from from_encoding.
Char * str_end(Char *str)
Return the end of a C-string, i.e. the pointer to the trailing NULL byte.
Definition: string.hpp:15
std::string from_utf(const CharType *begin, const CharType *end, const std::string &charset, method_type how=default_method)
convert UTF text in range [begin,end) to a text encoded with charset according to policy how
std::basic_string< CharType > to_utf(const char *begin, const char *end, const std::string &charset, method_type how=default_method)
convert text in range [begin,end) encoded with charset to UTF string according to policy how
method_type
enum that defines conversion policy
Definition: encoding_errors.hpp:41