Closed dezashibi closed 1 year ago
Thank you!
I prefer a function of that size to be in String.cpp
instead of in the header, though.
BTW, I think I understand why that failed. wcslen()
gives the number of wchar_t
, which here are UTF16 code units. So that will fail outside the BMP (e.g. emojis).
sure will move the function to String.cpp now
Done
Thinking again. Maybe that was intentional (it's old code): maybe we sometimes need the length in wchar_t units to pass it to functions using wide char strings (like the Windows API and others).
I'll merge this but analyze it again to see if we might need two functions, one for code points and one for wchar_t (UTF16 code units).
Thanks.
Sure, I'm going to be using this for a project, so it'll be many real world usecases and I'll be watching that
P.S. I already tested that in linux and windows, worked correctly
the count method calculates the number of actual character wrong in different situations such as one or many emojis, though the chars() works correctly and creates correct array of codepoints, so considering the functionality of chars() I've modified the count() function to fix this.