diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-04-28 14:27:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-28 14:27:56 +0200 |
commit | e71b05d365b35c889c53faaaa58e65f5efea4828 (patch) | |
tree | 17386207ee126a8c35c454e5534627052e59622c /platform/android/export/export.cpp | |
parent | d8066aa6a4afb12ffddcec71bd7e051dcd04f3e1 (diff) | |
parent | e74f8aaaf1720b0a6370205c8ef9d47028657889 (diff) |
Merge pull request #37193 from madmiraal/fix-android-export-unicode-errors
Fix Android export throwing Unicode errors.
Diffstat (limited to 'platform/android/export/export.cpp')
-rw-r--r-- | platform/android/export/export.cpp | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 71febd3433..d4fc52eaa9 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -1179,14 +1179,32 @@ class EditorExportPlatformAndroid : public EditorExportPlatform { static String _parse_string(const uint8_t *p_bytes, bool p_utf8) { uint32_t offset = 0; - uint32_t len = decode_uint16(&p_bytes[offset]); + uint32_t len = 0; if (p_utf8) { - //don't know how to read extended utf8, this will have to be for now - len >>= 8; + uint8_t byte = p_bytes[offset]; + if (byte & 0x80) + offset += 2; + else + offset += 1; + byte = p_bytes[offset]; + offset++; + if (byte & 0x80) { + len = byte & 0x7F; + len = (len << 8) + p_bytes[offset]; + offset++; + } else { + len = byte; + } + } else { + len = decode_uint16(&p_bytes[offset]); + offset += 2; + if (len & 0x8000) { + len &= 0x7FFF; + len = (len << 16) + decode_uint16(&p_bytes[offset]); + offset += 2; + } } - offset += 2; - //printf("len %i, unicode: %i\n",len,int(p_utf8)); if (p_utf8) { |