Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Hello Jake. I'm just posting some of my first impressions on your library.
- Also, I'm glad that you are developing this project I really miss some easy to use C++ library for working with utf-8 and unicode in general.
- My considerations:
- I missed a short example of a use case to figure out the most interesting facilities your library has to offer, a short example on the summary page would suffice.
- I have some doubts:
- - Can I convert other encodings to utf-8 and back? If yes which encodings? This would be great to make my library work on non-utf8 environments.
- - What is the return type of `operator[]`.
- You commented in the summary that this library is designed for C++11 projects but I tested a little hello world example using `g++ tinyutf8.cpp main.cpp && a.out` that worked fine, which is good =].
- ```C++
- #include <iostream>
- #include <string>
- #include "tinyutf8.h"
- int main(int argc, char* argv[]) {
- utf8_string str = "coração";
- std::cout << str.size() << std::endl; // 9
- std::cout << str.c_str() << std::endl; // "coração"
- std::cout << sizeof(str[4]) << std::endl; // 16
- }
- ```
- A suggestion: It might be interesting to add a function like this:
- ```C++
- std::ostream& operator<<(std::ostream& os, const utf8_string& t);
- ```
- So that I could print out the string easily with `std::cout << str << std::endl;`. Outputting the c_str() representation of the string might be enough and would probably make easier to make short examples using the library. However, I understand that there are some encoding concerns regarding the behavior of this function, maybe it is not the right time to implement it.
- Lastly, about your question on adapting the library for new types like `wchar_t` and `char32_t` or making it header only, I would vote for adapting it to use `char32_t` in special, since `wchar_t` implementations vary too much to use safely.
- I hope these suggestions help, I will finish reading the header and maybe I will use it.
Advertisement
Add Comment
Please, Sign In to add comment