-
Notifications
You must be signed in to change notification settings - Fork 82
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
refactor(to_string): change the behaviour of bytes to string #1141
base: main
Are you sure you want to change the base?
Conversation
BREAKING CHANGE for bytes to string
From the provided
These observations highlight areas where code redundancy, test consistency, and input validation could be improved to enhance the reliability and maintainability of the MoonBit codebase. |
Char::from_int('a'.to_int() + (i - 10)) | ||
} | ||
} | ||
|
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.
can we print ascii as is?
e.g, b"a\0b\0"
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.
IMO it's kinda hard to find the ascii inside a bunch of \00
.
Also encounter: Fatal error: exception File "inlined_snapshot/_build/Core_format.ml", line 200, characters 8-14: Assertion failed
. Investigating
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.
can we print ascii as is? e.g, b"a\0b\0"
displaying some byte as ASCII may not be a good idea. Bytes
are not always converted from a String, they may come from data of an image or some pieces of memory. ASCII is meaningless in such cases.
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.
Second this as UTF-16 encoded string has lots of \x00
and printing them is very ugly.
And Bytes
should just be Bytes
, it should print in Byte
format, not readble format.
Pull Request Test Coverage Report for Build 3820Details
💛 - Coveralls |
inspect!( | ||
"\n\t\"\\\r\b".to_bytes(), | ||
content= | ||
#|b"\n\x00\t\x00\"\x00\\\x00\r\x00\b\x00" |
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'm still not quite sure whether \n
should yield \\n
or \n
like this
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.
\\n
should never be used unless the user absolutely wants to see the backslash, which is typically not the case.
1be7f36
to
4f6bd42
Compare
BREAKING CHANGE for bytes to string