From f5b13062c314788ba8e4d84f3b530a5729db4c50 Mon Sep 17 00:00:00 2001 From: roker Date: Fri, 1 Oct 2021 09:10:10 +0200 Subject: [PATCH] start to encapsulate the functions in a class, to avoid the prohibition of partial function specialization. --- src/nfc.hh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/nfc.hh b/src/nfc.hh index a7d4154..d485e37 100644 --- a/src/nfc.hh +++ b/src/nfc.hh @@ -31,6 +31,20 @@ protected: }; +/// Common class template to define the same functions for all 3 Unicode Transfer Formats. +template +class UTF +{ +public: + /// parses a sequence of input code units into one Unicode code point and updates the input iterator c. + /// \todo change to iterator templates? + uint32_t parse(const CharT*& c, const CharT* end); + + /// generates a UTF sequence from a given Unicode code point + template + void generate(const char32_t c, OutIter& out); +}; + // scans the char sequences and parses UTF-8 sequences. Detect UTF-8 errors and throws exceptions. uint32_t parseUtf8(const char*& c, const char* end);