Skip to content

Commit

Permalink
Fix utf8 to unicode conversion
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas VIVIEN <nicolas@vivien.fr>
  • Loading branch information
progweb committed Aug 1, 2023
1 parent 6e60347 commit f248db1
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/libutil/strutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1436,13 +1436,15 @@ decode(uint32_t* state, uint32_t* codep, uint32_t byte)
void
Strutil::utf8_to_unicode(string_view str, std::vector<uint32_t>& uvec)
{
const char* begin = str.begin();
const char* end = str.end();
uint32_t state = 0;
const char* begin = str.begin();
const char* end = str.end();
uint32_t state = 0;
uint32_t codepoint = 0;
for (; begin != end; ++begin) {
uint32_t codepoint = 0;
if (!decode(&state, &codepoint, (unsigned char)*begin))
if (!decode(&state, &codepoint, (unsigned char)*begin)) {
uvec.push_back(codepoint);
codepoint = 0;
}
}
}

Expand Down

0 comments on commit f248db1

Please sign in to comment.