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

MemoryView: Prevent non-ascii characters #5294

Merged
merged 1 commit into from Jun 6, 2017

Conversation

sepalani
Copy link
Contributor

This PR prevents non-ascii characters to be printed in the MemoryView when set to view as ASCII. It shouldn't be seen as a replacement for PR #5293 as they address different issues.

Ready to be reviewed & merged.

@sepalani sepalani force-pushed the mem-view-ascii branch 2 times, most recently from 1cc93b4 to 36cda76 Compare April 21, 2017 00:42
@JosJuice
Copy link
Member

The implementation looks good assuming we indeed only want ASCII characters to be visible in the memory view. Most hex editors and similar software don't do that, though. They typically use an encoding like Windows-1252 for interpreting the data, since that makes more characters visible.

Does anyone else have an opinion on this?

@spycrab
Copy link
Contributor

spycrab commented Apr 21, 2017

I'd still opt for something similar to this.

str += static_cast<char>(byte);
char byte = static_cast<char>(mem_data >> (24 - i * 8) & 0xFF);
if (std::isprint(byte, std::locale::classic()))
str += byte;
else
str += ' ';

This comment was marked as off-topic.

This comment was marked as off-topic.

@sepalani
Copy link
Contributor Author

@JosJuice Most "useful" (free/open source) hex editors I know (i.e. MadEdit, WxMedit, wxHexEditor, etc.) don't use per se but let the users choose what encoding they should use. That's probably what we should do even though it isn't as simple as it sounds.

@spycrab Might be done in another PR. I also prefer dots over spaces since they are visible. However, I'd rather prefer a monospace-font usage regarding of the character used to replace invalid ASCII characters.

@spycrab
Copy link
Contributor

spycrab commented Apr 21, 2017

LGTM

@shuffle2 shuffle2 merged commit 2d941ad into dolphin-emu:master Jun 6, 2017
@sepalani sepalani deleted the mem-view-ascii branch June 6, 2017 04:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants