News for hackers. Stuff that matters.
Re:I'm Not a Fan of Strlcpy(3) by asveikau on Monday July 15, 2024 @09:49AM (#40967881)
I feel like this person went through an unnecessary and false tangent about how people are "afraid" of memcpy due to inexperience and missed the much more important criticism that arbitrary, naive truncation on a byte level doesn't play well with Unicode.
Re:I'm Not a Fan of Strlcpy(3) by aflag on Monday July 15, 2024 @04:17PM (#40971130)
Do the str* functions handle Unicode any better though? I feel like you'd want a different library for that
Re:I'm Not a Fan of Strlcpy(3) by ben_bai on Monday July 15, 2024 @07:23PM (#40972364)
that would be wcslcpy(3)
Re:I'm Not a Fan of Strlcpy(3) by asveikau on Monday July 15, 2024 @08:24PM (#40972642)
Nope. Unicode correctness is much more complicated than switching char to wchar_t. Many glyphs take multiple codepoints or multiple character units in either utf-16 or utf-8. You need something like the break iterator "character" separator in ICU.