██╗ ██╗████████╗███████╗ █████╗ ██████╗ ██║ ██║╚══██╔══╝██╔════╝██╔══██╗ ██╔════╝ ██║ ██║ ██║ █████╗ ╚█████╔╝ ██║ ██║ ██║ ██║ ██╔══╝ ██╔══██╗ ██║ ╚██████╔╝ ██║ ██║ ╚█████╔╝██╗╚██████╗ ╚═════╝ ╚═╝ ╚═╝ ╚════╝ ╚═╝ ╚═════╝ --------------------------------------------- simple C library for working with UTF-8 encoded strings
#include "utf8.h"
#include <stdio.h>
int main() {
const char* str = "Hello, こんにちは, Здравствуйте";
utf8_string ustr = make_utf8_string(str);
utf8_string_slice slice = make_utf8_string_slice(ustr, 2, 11);
utf8_char_iter iter = make_utf8_char_iter(ustr);
printf("string: %s\n", ustr.str);
printf("slice: %.*s\n", (int)slice.byte_len, slice.str);
utf8_char ch;
while ((ch = next_utf8_char(&iter)).byte_len > 0) {
printf("character: %.*s\t", (int)ch.byte_len, ch.str);
printf("unicode code point: U+%04X\n", unicode_code_point(ch));
}
return 0;
}
M. Zahash – [email protected]
Distributed under the MIT license. See LICENSE
for more information.
- Fork it (https://github.com/zahash/utf8.c/fork)
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request
If you find this helpful and enjoy using it, consider giving it a ⭐ on GitHub! Your star is a gesture of appreciation and encouragement for the continuous improvement of this library.