sheredom / utf8.h

📚 single header utf8 string functions for C and C++
The Unlicense
1.69k stars 123 forks source link

fix for issue 109 #110

Closed curoles closed 11 months ago

curoles commented 1 year ago

https://github.com/sheredom/utf8.h/issues/109

curoles commented 1 year ago

let me check failing tests

curoles commented 11 months ago

Test UTEST(utf8ncpy, truncated_copy_null_terminated) fails. Someone with better understanding of what this test is expecting should have a look.

If char cpy2[2] = {'\0'}; and const char data[] = { '\xce', '\x93',... then I am not sure why following must be true:

  utf8ncpy(cpy2, data, 2);
  ASSERT_EQ('\0', cpy2[0]);
curoles commented 11 months ago

I added a print-out to make sure where/how exactly the test fails, as I suspected it fails at ASSERT_EQ('\0', cpy2[0]);:

cpy2[0]=ce, cpy2[1]=93
curoles commented 11 months ago

I believe I fixed one more issue when destination string it too small to store codepoint plus null terminator. All tests are passing, nevertheless, check if my last fix makes sense.