sheredom / utf8.h

📚 single header utf8 string functions for C and C++
The Unlicense
1.69k stars 123 forks source link

Not an issue #83

Closed ridams closed 3 years ago

ridams commented 3 years ago

How to loop through a utf8 str like :

for (int =0;i<strlen(*char);i++) do_somethingwith *char_[i]

sheredom commented 3 years ago

You do:

utf8_int32_t codepoint;
for (void* next = utf8codepoint(ptr, &codepoint); codepoint != 0; next = utf8codepoint(next, &codepoint)) {
  // codepoint is your current utf-8 codepoint
}