Browse Source

add isUtf8(const char* begin, const char* end).

afl-fuzzing
Roker 3 years ago
parent
commit
40471a4d5a
2 changed files with 14 additions and 0 deletions
  1. +11
    -0
      src/nfc.cc
  2. +3
    -0
      src/nfc.hh

+ 11
- 0
src/nfc.cc View File

@ -466,6 +466,17 @@ bool isNFC(const std::string& s)
throw -1; // could never happen, but compiler is too dumb to see this.
}
bool isUtf8(const char* begin, const char* end)
try{
for(; begin<end; ++begin)
{
(void)parseUtf8(begin, end);
}
return true;
}catch(const illegal_utf8&)
{
return false;
}
// s is ''moved'' to the return value if possible so no copy is done here.
std::string toNFC(std::string s)


+ 3
- 0
src/nfc.hh View File

@ -46,6 +46,9 @@ 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);
// returns true if the sequence is valid UTF-8
bool isUtf8(const char* begin, const char* end);
// 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.
std::string toNFC(std::string s);


Loading…
Cancel
Save