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

Add support for Unicode strings to the interpreter #76

Open
willcrichton opened this issue May 10, 2023 · 2 comments
Open

Add support for Unicode strings to the interpreter #76

willcrichton opened this issue May 10, 2023 · 2 comments
Labels

Comments

@willcrichton
Copy link
Collaborator

Right now, the interpreter shows Unicode strings as random characters. For example, given this snippet from the Rust Book:

fn main() {
    let hello = String::from("السلام عليكم");
}

Then Aquascope generates the following heap:

Screen Shot 2023-05-09 at 5 20 58 PM

The issue is that Strings are serialized as a vector of chars here:

Some(MHeapAllocKind::String { len }) => {
let array =
self.read_array(base, base.layout.size, *len, base.layout.ty)?;
let MValue::Array(values) = array else { unreachable!() };
let chars = values.map(|el| {
let MValue::Uint(c) = el else { unreachable!() };
MValue::Char(c as usize)
});
MValue::Array(chars)

And then each char is individually converted back to a character here:

String.fromCharCode(value.value).replace(" ", "\u00A0")

But that strategy doesn't work for non-ASCII strings.

@willcrichton willcrichton added the good first issue Good for newcomers label May 10, 2023
@safwansamsudeen
Copy link

Could I take this up? I'm new to Rust, so I'll take some time, if that's alright.

@willcrichton
Copy link
Collaborator Author

@safwansamsudeen sure thing. Feel free to post in this thread if you have any issues getting started.

@safwansamsudeen safwansamsudeen removed their assignment Apr 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants