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

More fixes to String#inspect #1841

Merged
merged 5 commits into from
Feb 26, 2024
Merged

Conversation

herwinw
Copy link
Member

@herwinw herwinw commented Feb 26, 2024

This closes #1840

The decision whether a character should be escaped is moved from StringObject to EncodingObject, this needs to be encoding aware too. Only UTF8 has a sensible printable member function, all other encodings work according to the specs (which probably means there are no specs).
This fixes the YAML escape issue mentioned in #1839 as well, running the full upstream specs of String#dump and String#inspect now results in valid YAML output, so the issue with spec results not showing up in the overview should be resolved as well (the double free issue with the YAML lib is still relevant though)

Increase the data type to support multibyte chars.
It still isn't perfect, but this gets 2 more specs running.
The failing specs imply the behaviour depends on the character encoding,
so we should probably move the inner loop of inspect from StringObject
to EncodingObject.
Add a default implementation that works for ASCII ranges.
This one makes sure we print the extended characters for unicode
strings.
@herwinw herwinw merged commit 2ca59b8 into natalie-lang:master Feb 26, 2024
12 checks passed
@herwinw herwinw deleted the string_escape branch February 26, 2024 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong data type in EncodingObject::escaped_char
2 participants