-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Salvage #13772 #13935
Salvage #13772 #13935
Conversation
Allow to convert from UTF-8 to whatever encoding the device supports
f4219e9
to
bd5996c
Compare
bd5996c
to
d131d1c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Returning part of a usable result instead of nullbytes since those likely terminate the string early or even corrupt the underlying binary message format the buffer is embedded in.
src/controllers/scripting/legacy/controllerscriptinterfacelegacy.h
Outdated
Show resolved
Hide resolved
const char* encoderName = encoderNameArray.constData(); | ||
#endif | ||
QStringEncoder fromUtf16 = QStringEncoder(encoderName); | ||
if (!fromUtf16.isValid()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why you removed the flags here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see the commit message, writing the replacement char is better than replacing with null bytes IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may be a problem. During the tests I noticed that replacement char varies between Ubuntu and Fedora (maybe between Qt versions). Replace invalid chars with \0x00
is the most predictable option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure? I think it depends on the encoding. The Qt docs say they use QChar::ReplacementCharacter
or a question mark.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what I noticed here. The relevant commit is probably this one. Although I tested your branch and the tests pass here too so I'm not sure anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try to reproduce later this week if I have time but I don't think this should be a blocker. We'll have time to change it later or introduce a new API if this proves unstable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about QStringEncoder::Flag::WriteBom
?
Should we set it or not? I think it's easier to remove a unwanted BOM in JavaScript, than to add the correct BOM in JavaScript.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@christophehenry The flags here are the last open point, did you find to check this out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sorry I didn't know you were waiting for me. I couldn't reproduce this. Feel free to merge as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, than lets merge this!
src/controllers/scripting/legacy/controllerscriptinterfacelegacy.cpp
Outdated
Show resolved
Hide resolved
Since this PR implements the consensus, can I close #13772? |
@JoergAtGithub Anything left to do here? Pre-commit failure is unrelated. The commit history is garbage so I'd like to squash everything into a single commit. |
c992b43
to
3101eff
Compare
Simplified alternative of #13772 which implements the original scope I proposed.
CC @christophehenry @JoergAtGithub