| Boost.Locale

encoding.hpp
1//
2// Copyright (c) 2022-2023 Alexander Grund
3//
4// Distributed under the Boost Software License, Version 1.0.
5// https://www.boost.org/LICENSE_1_0.txt
6
7#ifndef BOOST_LOCALE_DETAIL_ENCODING_HPP_INCLUDED
8#define BOOST_LOCALE_DETAIL_ENCODING_HPP_INCLUDED
9
10#include <boost/locale/config.hpp>
11#include <boost/locale/encoding_errors.hpp>
12#include <boost/utility/string_view.hpp>
13#include <memory>
14#include <string>
15
17 namespace boost { namespace locale { namespace conv { namespace detail {
18 template<typename CharIn, typename CharOut>
19 class BOOST_SYMBOL_VISIBLE charset_converter {
20 public:
21 using char_out_type = CharOut;
22 using char_in_type = CharIn;
23 using string_type = std::basic_string<CharOut>;
24
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)
28 {
29 return convert(text.data(), text.data() + text.length());
30 }
31 };
32
33 using narrow_converter = charset_converter<char, char>;
34
35 template<typename CharType>
36 using utf_encoder = charset_converter<char, CharType>;
37
38 template<typename CharType>
39 using utf_decoder = charset_converter<CharType, char>;
40
41 enum class conv_backend { Default, IConv, ICU, WinAPI };
42
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,
52 method_type how,
53 conv_backend impl = conv_backend::Default);
54}}}} // namespace boost::locale::conv::detail
55
57
58#endif
boost::locale::category_t::convert
@ convert
Generate conversion facets.
- © Copyright 2009-2012 Artyom Beilis, Distributed under the Boost Software License, Version 1.0.