-
-
Notifications
You must be signed in to change notification settings - Fork 22.1k
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 String::ascii
creator functions, to parse a char buffer as ASCII.
#101304
Conversation
21364f4
to
0d288be
Compare
Tests were failing because of implicit conversions, but it should work fine on top of #101293. I have rebased the PR accordingly. |
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.
It's definitely cleaner to have dedicated functions for these.
4194cf0
to
5022418
Compare
#101293 has been merged, this is ready for a rebase! |
The function will log errors if any characters above value 127 are found.
5022418
to
b6cfcde
Compare
Rebase complete! PR is looking much cleaner now =) |
Thanks! |
The function will log errors if any characters above value 127 are found. This is most similar to
parse_latin1
, butparse_latin1
will silently and incorrectly parse values above 127 as 'extended latin set' characters, whenASCII
only is expected. This would be especially incorrect if the input isutf8
, because the string will silently have incorrect length and misinterpreted characters.As discussed in #101293 (comment), two functions in
plist
are known to expectASCII
-only strings, so they are used as an excuse to call the new function. It would be correct to callparse_ascii
on many other occasions (see #100641), but I do not have the broad knowledge to search out all these instances. Instead, the function is added here such that future contributions can call it to safely parseASCII
when it is expected.Requires and includes #101293 (because of implicit conversions).