first NFC quick check, than (yet unimplemented) deep check

Roker 7 years ago
parent 0072632a88
commit 6b075d85a5

@ -159,7 +159,7 @@ illegal_utf8::illegal_utf8( const std::string& msg )
IsNFC isNFC(const std::string& s)
IsNFC isNFC_quick_check(const std::string& s)
const char* begin =;
const char* const end = + s.size();
@ -180,15 +180,29 @@ IsNFC isNFC(const std::string& s)
return IsNFC::Yes;
bool isNFC(const std::string& s)
switch( isNFC_quick_check(s) )
case IsNFC::Yes : return true;
case IsNFC::No : return false;
case IsNFC::Maybe:
throw std::logic_error("Deep NGC check is not yet implemented. Sorry.");
throw -1; // could never happen, but compiler is too dumb to see this.
// s is ''moved'' to the return value if possible so no copy is done here.
std::string toNFC(std::string s)
return s;
std::string ret;
// TODO:
return ret;
throw std::logic_error("NFC normalization is necessary, but unimplemented. Sorry.");

@ -23,7 +23,10 @@ protected:
// return No or Maybe, if at least one character with NFC_Quickcheck class is "No" or "Maybe"
// might throw illegal_utf8 exception
IsNFC isNFC(const std::string& s);
IsNFC isNFC_quick_check(const std::string& s);
// runs first quick check and a deep test if quick check returns "Maybe".
bool isNFC(const std::string& s);
// converts a C++ string (in UTF-8) into NFC form
// s is ''moved'' to the return value if possible so no copy is done here.