Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4 byte GB18030 character convert to Unicode ERROR #2

Open
cnldw opened this issue May 22, 2023 · 0 comments
Open

4 byte GB18030 character convert to Unicode ERROR #2

cnldw opened this issue May 22, 2023 · 0 comments

Comments

@cnldw
Copy link

cnldw commented May 22, 2023

There is a bug in line 185 of the qt5compat/src/core5/codecs/qgb18030codec.cpp file

The length of Unicode characters generated after encoding with 4-byte GB18030 may be longer than 2 bytes, but QString default can only store 2-byte Unicode characters. Therefore, optimization is needed to store greater than 2 bytes GB18030 characters as proxies, otherwise, some 4-byte GB18030 characters will be converted to other characters during encoding into Qstring. Here is an optimization suggestion:

                  if (u>0xFFFF){
                  resultData[unicodeLen] = QChar::highSurrogate(u);
                  ++unicodeLen;
                  resultData[unicodeLen] = QChar::lowSurrogate(u);
                  ++unicodeLen;
                }
                else{
                resultData[unicodeLen] = qValidChar(u);
                ++unicodeLen;
                }

There is a bug in line 8883 of the qt5compat/src/core5/codecs/qgb18030codec.cpp file
0xE248 should be changed to 0x1E248

            } else if (InRange(gb4lin, 0x2E248, 0x12E247)) {
                /* GB+90308130 - GB+E3329A35 */
                uni = gb4lin - 0x1E248;
            } else {
                /* undefined or reserved area */
                len = 1;
                uni = QChar::ReplacementCharacter;
            }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant