cordova-plugin-file icon indicating copy to clipboard operation
cordova-plugin-file copied to clipboard

FileReader splits special characters up which leads to exception and null result

Open ExtraFisch opened this issue 2 years ago • 0 comments
trafficstars

Bug Report

What is expected to happen?

The FileReader should read a file correctly.

What does actually happen?

FileReader returns null

Information

Today i noticed a special case where I was reading a JSON file with the FileReader. It returned null for some reason. When I made a small change to the file it worked. I debugged into it and found out that the FileReader has this READ_CHUNK_SIZE. It splits the file into chunks while reading. At some point it creates a string out if the byte buffer again. At this point the exception occures as the reader read just half of a special character into the buffer. Thats because special UTF-8 characters can be represented by more than one byte. In my case it was a degree sign "°".

ExtraFisch avatar Mar 10 '23 19:03 ExtraFisch