diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..285d10a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +test.cpp +a.out diff --git a/README.md b/README.md index 6f79469..00bf102 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,39 @@ I expect the performance to be abysmally slow and for it to not really be worth To use it, just include "utf8.h" or whatever the file name is at the current moment in time. I'll /probably (not)?/ update this in the future. CC0 because I don't deserve credit for how awful this is. + +Some example code because why not. + +Printing a string: +```cpp +#include +#include "utf8.h" + +int main() { + string32 test = "こんにちは!"; + std::cout << test << "\n"; +} +``` + +Getting the third character of a string, without breaking UTF-8 strings. +```cpp +#include +#include "utf8.h" + +int main() { + string32 test = "こんにちは!"; + std::cout << "The third character of `" << test << "` is: " << test[2] << "\n"; +} +``` + +Iterating over a string: +```cpp +#include +#include "utf8.h" + +int main() { + string32 test = "こんにちは!"; + for (int i(0);i