Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd in null terminator for outputs in cu_shorten/cu_widen in cute_utf.h #75
Comments
|
Also some feedback regarding your example tuWiden functions in #74 (comment) The 3rd and the 4th functions are likely going to be the most commonly used ones, the others are subsets of the 3rd and 4th function. I would use the 4th function on say, internal strings that I know are safe, but if I need extra validating (example: non-null terminated text from foreign sources) I can use the 3rd function. |
|
Did you mean:
? (added *out instead of just out) |
|
yes |
|
Can i do this one? |
|
Yes of course :) |
|
I can't seem to find tinyutf.h and what are tuShorten/tuWiden functions? do I need to read up something before i attempt to do this? |
|
The prefix of the header files changed to cute, so you‘re looking for |
|
Ah yes a while ago I renamed things. The file is https://github.com/RandyGaul/cute_headers/blob/master/cute_utf.h The widen/shorten functions are used to convert to utf16 and back to utf8 respectively. The docs has some more info on why this conversion is useful (it's just useful for some Windows APIs that need 16-bit characters, aka utf16). Let me know if you had other questions :) |
|
thanks, is there a way to test or build this once i make the changes? |
|
There is a little bit of testing here: https://github.com/RandyGaul/cute_headers/tree/master/test_cute_utf If you like, you can add more tests in whatever manner you think makes sense. I would be more than happy to incorporate them if you write any down! |


I've been treating tuShorten/tuWiden as a string-ish conversion between UTF16 and UTF 8, so I recommend this.
Here's the code; add it to the end of every tuShorten/tuWiden function.
if (out < (original_out + out_len)) out = 0;