You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added separate functions UnicodeToWtf8() and Wtf8ToUnicode() to fix an old bug in Android
that older than M (API23), which can't process 4-byte UTF-8 sequences.
How to reproduce this bug: just open a text file with such UTF-8 sequences and you will get
a crash with the following error: "input is not valid Modified UTF-8: illegal start byte 0xf0".
Reason: unhandled exception: 'input is not valid Modified UTF-8: illegal start byte 0xf0'.
stack trace (for commit a1bf2be):
_JNIEnv::NewStringUTF(char const*) // jni.h:841
jstring CRJNIEnv::toJavaString( const lString16 & str ) // cr3java.cpp:18
void CRStringField::set( const lString16& str) // cr3java.h:165
JNIEXPORT jobject JNICALL Java_org_coolreader_crengine_DocView_getPositionPropsInternal
(JNIEnv * _env, jobject _this, jstring _path) // docview.cpp:1662
at org.coolreader.crengine.DocView.getPositionPropsInternal(Native Method)
at org.coolreader.crengine.DocView.getPositionProps(DocView.java:270)
at org.coolreader.crengine.ReaderView.preparePageImage(ReaderView.java:3248)
at org.coolreader.crengine.ReaderView.access$1700(ReaderView.java:42)
at org.coolreader.crengine.ReaderView$LoadDocumentTask.work(ReaderView.java:4829)
at org.coolreader.crengine.Engine$TaskHandler.run(Engine.java:180)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at org.coolreader.crengine.BackgroundThread.run(BackgroundThread.java:122)
And solution: just don't pass such strings to env->NewStringUTF(), but pass WTF-8 strings.
But this don't fix the crash when CoolReader finds files whose names contain such characters!
0 commit comments