Closed remyjette closed 2 years ago
Hi Remy,
This was an intentional change. The idea is if we need to pass non-string data, then we should explicitly use other types, such as binary
or DataView
, DataRef
. If we do specify string
, then it needs to be a valid string. C++ allows its string
s to contain invalid codepoints but these do not map to other languages without loss of information.
We want this kind of errors to be detected earlier in the development cycle rather than failing silently and lead to unintended behavior.
Thanks for the explanation!
Hi there,
Thanks for taking over development of Djinni! My app still usees dropbox/djinni, and I'm looking to switch over.
One thing I noticed is that jni/djinni_support.cpp now uses
codecvt_utf8_utf16
which was deprecated in C++17 (and I believe is why dropbox/djinni wasn't using it)This also had a pretty severe side effect: Previously Djinni had a function
utf8_decode_check
to validate that the givenstd::string
was actually UTF8 before trying to convert it. Now this check is gone, and so trying to convert a string that contains invalid characters throwsstd::range_error
instead of just returning0xFFFD
: https://godbolt.org/z/6x59nT3T8 (code copied from dropbox/djinni djinni_support.cpp and snapchat/djinni djinni_support.cpp)