Moved Odaki's implemetation of searching for end of utf8 sequence to separate function.

+ Fix of 0xC0 in trailer bytes 
followup on fff862a5ae
This commit is contained in:
David Kocik 2022-01-05 12:37:07 +01:00
parent fff862a5ae
commit 3f14484eca
4 changed files with 72 additions and 101 deletions

View file

@ -74,6 +74,10 @@ extern local_encoded_string encode_path(const char *src);
extern std::string decode_path(const char *src);
extern std::string normalize_utf8_nfc(const char *src);
// Returns next utf8 sequence length. =number of bytes in string, that creates together one utf-8 character.
// Starting at pos. ASCII characters returns 1. Works also if pos is in the middle of the sequence.
extern size_t get_utf8_sequence_length(const std::string& text, size_t pos = 0);
// Safely rename a file even if the target exists.
// On Windows, the file explorer (or anti-virus or whatever else) often locks the file
// for a short while, so the file may not be movable. Retry while we see recoverable errors.