https://github.com/zahash/utf8.c
UTF-8 library for c
https://github.com/zahash/utf8.c
Last synced: about 1 year ago
JSON representation
UTF-8 library for c
- Host: GitHub
- URL: https://github.com/zahash/utf8.c
- Owner: zahash
- License: mit
- Created: 2024-03-17T11:06:00.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-10T11:12:09.000Z (almost 2 years ago)
- Last Synced: 2025-04-19T03:34:20.041Z (about 1 year ago)
- Language: C
- Homepage:
- Size: 48.8 KB
- Stars: 16
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
██╗ ██╗████████╗███████╗ █████╗ ██████╗
██║ ██║╚══██╔══╝██╔════╝██╔══██╗ ██╔════╝
██║ ██║ ██║ █████╗ ╚█████╔╝ ██║
██║ ██║ ██║ ██╔══╝ ██╔══██╗ ██║
╚██████╔╝ ██║ ██║ ╚█████╔╝██╗╚██████╗
╚═════╝ ╚═╝ ╚═╝ ╚════╝ ╚═╝ ╚═════╝
---------------------------------------------
simple C library for working with UTF-8 encoded strings
[](https://opensource.org/licenses/MIT)
## 🧑💻 Usage example
```c
#include "utf8.h"
#include
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;
}
```
## 🌟 Connect with Us
M. Zahash – zahash.z@gmail.com
Distributed under the MIT license. See `LICENSE` for more information.
[https://github.com/zahash/](https://github.com/zahash/)
## 🤝 Contribute to utf8.c!
1. Fork it ()
2. Create your feature branch (`git checkout -b feature/fooBar`)
3. Commit your changes (`git commit -am 'Add some fooBar'`)
4. Push to the branch (`git push origin feature/fooBar`)
5. Create a new Pull Request
## ❤️ Show Some Love!
If you find this helpful and enjoy using it, consider giving it a [⭐ on GitHub!](https://github.com/zahash/utf8.c/stargazers) Your star is a gesture of appreciation and encouragement for the continuous improvement of this library.