File indexing completed on 2025-01-18 09:39:15
0001
0002
0003
0004
0005
0006
0007 #ifndef BOOST_LOCALE_DETAIL_ENCODING_HPP_INCLUDED
0008 #define BOOST_LOCALE_DETAIL_ENCODING_HPP_INCLUDED
0009
0010 #include <boost/locale/config.hpp>
0011 #include <boost/locale/encoding_errors.hpp>
0012 #include <boost/utility/string_view.hpp>
0013 #include <memory>
0014 #include <string>
0015
0016
0017 namespace boost { namespace locale { namespace conv { namespace detail {
0018 template<typename CharIn, typename CharOut>
0019 class BOOST_SYMBOL_VISIBLE charset_converter {
0020 public:
0021 using char_out_type = CharOut;
0022 using char_in_type = CharIn;
0023 using string_type = std::basic_string<CharOut>;
0024
0025 virtual ~charset_converter() = default;
0026 virtual string_type convert(const CharIn* begin, const CharIn* end) = 0;
0027 string_type convert(const boost::basic_string_view<CharIn>& text)
0028 {
0029 return convert(text.data(), text.data() + text.length());
0030 }
0031 };
0032
0033 using narrow_converter = charset_converter<char, char>;
0034
0035 template<typename CharType>
0036 using utf_encoder = charset_converter<char, CharType>;
0037
0038 template<typename CharType>
0039 using utf_decoder = charset_converter<CharType, char>;
0040
0041 enum class conv_backend { Default, IConv, ICU, WinAPI };
0042
0043 template<typename Char>
0044 BOOST_LOCALE_DECL std::unique_ptr<utf_encoder<Char>>
0045 make_utf_encoder(const std::string& charset, method_type how, conv_backend impl = conv_backend::Default);
0046 template<typename Char>
0047 BOOST_LOCALE_DECL std::unique_ptr<utf_decoder<Char>>
0048 make_utf_decoder(const std::string& charset, method_type how, conv_backend impl = conv_backend::Default);
0049 BOOST_LOCALE_DECL std::unique_ptr<narrow_converter>
0050 make_narrow_converter(const std::string& src_encoding,
0051 const std::string& target_encoding,
0052 method_type how,
0053 conv_backend impl = conv_backend::Default);
0054 }}}}
0055
0056
0057
0058 #endif