summaryrefslogtreecommitdiffhomepage
path: root/include/unicode.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/unicode.h')
-rw-r--r--include/unicode.h24
1 files changed, 13 insertions, 11 deletions
diff --git a/include/unicode.h b/include/unicode.h
index 502ec16..33b3199 100644
--- a/include/unicode.h
+++ b/include/unicode.h
@@ -19,8 +19,10 @@
#ifdef __cpp_char8_t
// char8_t available
typedef char8_t utf8_t;
+ typedef char iso_t;
#else
typedef char utf8_t;
+ typedef char iso_t;
#endif
namespace unicode {
@@ -353,10 +355,10 @@ namespace unicode::detail {
typedef std::unordered_map<char32_t, utf8_t> iso_map_type_reverse;
// ISO-8859-1 is lower 8-bit of Unicode, so no exceptions necessary
- iso_map_type iso_8859_1_map;
+ static inline iso_map_type iso_8859_1_map;
// ISO-8859-15 is lower 8-bit of Unicode, except for:
- iso_map_type iso_8859_15_map {
+ static inline iso_map_type iso_8859_15_map {
{ '\xA4', U'\u20AC' }, // €
{ '\xA6', U'\u0160' }, // Š
{ '\xA8', U'\u0161' }, // š
@@ -367,7 +369,7 @@ namespace unicode::detail {
{ '\xBE', U'\u0178' }, // Ÿ
};
- iso_map_type_reverse reverse_iso_map(const iso_map_type& map) {
+ inline iso_map_type_reverse reverse_iso_map(const iso_map_type& map) {
iso_map_type_reverse result;
std::for_each(map.cbegin(), map.cend(),
[&](const iso_map_type::value_type& pair)
@@ -377,8 +379,8 @@ namespace unicode::detail {
return result;
}
- iso_map_type_reverse iso_8859_15_map_reverse { reverse_iso_map(iso_8859_15_map) };
- iso_map_type_reverse iso_8859_1_map_reverse { reverse_iso_map(iso_8859_1_map) };
+ static inline iso_map_type_reverse iso_8859_15_map_reverse { reverse_iso_map(iso_8859_15_map) };
+ static inline iso_map_type_reverse iso_8859_1_map_reverse { reverse_iso_map(iso_8859_1_map) };
} // namespace unicode::detail
@@ -386,9 +388,9 @@ namespace unicode {
using namespace detail;
- template<unicode::detail::iso_map_type& Map=iso_8859_1_map, typename Container=std::basic_string<utf8_t>>
+ template<unicode::detail::iso_map_type& Map=iso_8859_1_map, typename Container=std::basic_string<iso_t>>
struct iso_iterator {
- typedef utf8_t input_type;
+ typedef iso_t input_type;
typedef char32_t value_type;
typedef char32_t& reference;
typedef char32_t* pointer;
@@ -414,7 +416,7 @@ namespace unicode {
// return reference?
value_type operator*()
{
- utf8_t value{*m_it};
+ input_type value{*m_it};
if constexpr(std::addressof(Map) != std::addressof(iso_8859_1_map)) // mapping of 128 <= x <= 255 needed
{
@@ -429,12 +431,12 @@ namespace unicode {
iterator m_it;
};
- template<unicode::detail::iso_map_type_reverse& Map=iso_8859_1_map_reverse, typename Container=std::basic_string<utf8_t>>
+ template<unicode::detail::iso_map_type_reverse& Map=iso_8859_1_map_reverse, typename Container=std::basic_string<iso_t>>
struct iso_back_insert_iterator {
typedef iso_back_insert_iterator& reference;
typedef iso_back_insert_iterator* pointer;
typedef size_t difference_type;
- typedef utf8_t value_type;
+ typedef iso_t value_type;
typedef std::output_iterator_tag iterator_category;
typedef Container string_type;
@@ -486,7 +488,7 @@ namespace unicode {
template<typename InputIt, typename OutputIt>
struct ISO_8859
{
- typedef utf8_t value_type;
+ typedef iso_t value_type;
typedef typename InputIt::string_type string_type;
static InputIt begin(const typename InputIt::string_type& s)