-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
tryparse can throw InvalidCharError #32314
Comments
tryparse
can throw InvalidCharError
Definitely a bug. The whole point of |
I looked into a fix for this and I also came across the following possible bug: julia> badchar = reinterpret(Char, UInt32(0x64000BAD))
'\x64\x00\x0b\xad': Malformed UTF-8 (category Ma: Malformed, bad data)
julia> UInt32(badchar)
0x00000064
julia> Char(UInt32(badchar))
'd': ASCII/Unicode U+0064 (category Ll: Letter, lowercase) This is due to the code at Lines 124 to 127 in 0af2f74
The Lines 39 to 46 in 0af2f74
Which one is wrong; the documentation or the implementation? It seems that changing the check |
I’ll take a look next week. Can you bump the issue so I don’t forget? I really wish GitHub allowed one to snooze an issue or PR. |
Sure thing. See the branch https://github.com/JuliaLang/julia/tree/cjf/tryparse-fix-invalid-char-error for one fast way to fix this, mirroring what's done in |
That seems pretty good to me. |
According to the
tryparse
docs,tryparse
is meant to returnnothing
if the string doesn't contain a valid number. I just got the following surprise:I'm not quite sure whether this is a bug, or whether it's up to the user to validate the
String
s they're passing around.The text was updated successfully, but these errors were encountered: