7#ifndef BOOST_LOCALE_DETAIL_ENCODING_HPP_INCLUDED
8#define BOOST_LOCALE_DETAIL_ENCODING_HPP_INCLUDED
10#include <boost/locale/config.hpp>
11#include <boost/locale/encoding_errors.hpp>
12#include <boost/utility/string_view.hpp>
17namespace boost {
namespace locale {
namespace conv {
namespace detail {
18 template<
typename CharIn,
typename CharOut>
19 class BOOST_SYMBOL_VISIBLE charset_converter {
21 using char_out_type = CharOut;
22 using char_in_type = CharIn;
23 using string_type = std::basic_string<CharOut>;
25 virtual ~charset_converter() =
default;
26 virtual string_type
convert(
const CharIn* begin,
const CharIn* end) = 0;
27 string_type
convert(
const boost::basic_string_view<CharIn>& text)
29 return convert(text.data(), text.data() + text.length());
33 using narrow_converter = charset_converter<char, char>;
35 template<
typename CharType>
36 using utf_encoder = charset_converter<char, CharType>;
38 template<
typename CharType>
39 using utf_decoder = charset_converter<CharType, char>;
41 enum class conv_backend { Default, IConv, ICU, WinAPI };
43 template<
typename Char>
44 BOOST_LOCALE_DECL std::unique_ptr<utf_encoder<Char>>
45 make_utf_encoder(
const std::string& charset, method_type how, conv_backend impl = conv_backend::Default);
46 template<
typename Char>
47 BOOST_LOCALE_DECL std::unique_ptr<utf_decoder<Char>>
48 make_utf_decoder(
const std::string& charset, method_type how, conv_backend impl = conv_backend::Default);
49 BOOST_LOCALE_DECL std::unique_ptr<narrow_converter>
50 make_narrow_converter(
const std::string& src_encoding,
51 const std::string& target_encoding,
53 conv_backend impl = conv_backend::Default);
@ convert
Generate conversion facets.