Issue
Most of the time I use UTF-8 on Android but I'm recently testing wchar_t
too.
I know wchar_t
was horrible in the early days, but I don't care about too old devices so thought it would be fine to work with wchar_t
now.
Tested on:
Physical devices: Samsung Galaxy Note2 (4.4.2), Galaxy S7 Edge (7.0)
Software emulators: HTC One (4.3), Samsung Galaxy S6 (5.0, 6.0), S8 (7.0), Google Pixel C (7.1.0)
In my simple tests, wcslen()
, wcscpy()
, wcscat()
worked as expected,
but swprintf()
did nothing on HTC One (4.3) and Note2(4.4.2).
I couldn't test all the devices out there, but my conclusion is that swprintf()
just doesn't work on Android Kitkat and below. It may just return doing nothing.
Could someone confirm my theory, please? Is there any workaround for this?
Whether practical or not, I just want to know.
Solution
Don't ask me why, but until L Android only had a stub implementation of vswprintf
that just returns -1.
https://android.googlesource.com/platform/bionic/+/kitkat-release/libc/bionic/wchar.cpp#74
The workaround would be to use libandroid_support. This is automatic if you're using libc++ (and that's the best option for NDK r16+).
Answered By - Dan Albert
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.