From 563557be9c97496b7435bef4e64730a379e55037 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Tue, 28 Dec 2021 14:35:36 +0100 Subject: UTF and ISO are Encodings, not Facets --- include/unicode.h | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'include') diff --git a/include/unicode.h b/include/unicode.h index be91d77..4e4c7eb 100644 --- a/include/unicode.h +++ b/include/unicode.h @@ -576,7 +576,7 @@ namespace unicode { typename iso_back_insert_iterator::string_type& s; }; - // Facet for convert() and ISO-8859-* + // Encoding for convert() and ISO-8859-* template struct ISO_8859 { @@ -599,7 +599,7 @@ namespace unicode { } }; - // Facet for convert() and UTF-* + // Encoding for convert() and UTF-* template struct UTF { @@ -622,7 +622,7 @@ namespace unicode { } }; - // Facet for convert() + // Encoding for convert() typedef ISO_8859, iso_back_insert_iterator<>> ISO_8859_1; typedef ISO_8859, iso_back_insert_iterator> ISO_8859_15; @@ -731,7 +731,7 @@ namespace unicode { }; // class ArchitectureOptimizer - // From and To are facets + // From and To are Encodings template::value, bool> = true> typename To::string_type convert_optimized(const typename From::string_type& s) { @@ -777,7 +777,7 @@ namespace unicode { return result; } - // From and To are facets + // From and To are Encodings template::value, bool> = true> typename To::string_type convert(const typename From::string_type& s) { @@ -799,7 +799,7 @@ namespace unicode { } } - // Helper to get correct Facet from char type, e.g. Encoding::Facet + // Helper to get correct Encoding from char type, e.g. Encoding::type or Encoding_t template struct Encoding { @@ -808,21 +808,24 @@ namespace unicode { template<> struct Encoding { - typedef UTF_8 Facet; + typedef UTF_8 type; }; template<> struct Encoding { - typedef UTF_16 Facet; + typedef UTF_16 type; }; template<> struct Encoding { - typedef UTF_32 Facet; + typedef UTF_32 type; }; + template + using Encoding_t = typename Encoding::type; + // From and To are from: utf8_t (i.e. char or char8_t (C++20)), char16_t and char32_t, char, wchar_t, uint8_t, uint16_t, uint32_t template, @@ -884,11 +887,11 @@ namespace unicode { return true; } - // Facet version - template::value, bool> = true> - bool is_valid_utf(const typename Facet::string_type& s) + // Encoding version + template::value, bool> = true> + bool is_valid_utf(const typename Encoding::string_type& s) { - return validate_utf(s); + return validate_utf(s); } } // namespace unicode -- cgit v1.2.3