-
Notifications
You must be signed in to change notification settings - Fork 95
builtin: Implement builtin_ascii #66
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
Conversation
@ncw |
Codecov Report
@@ Coverage Diff @@
## master #66 +/- ##
==========================================
+ Coverage 68.61% 68.63% +0.01%
==========================================
Files 59 59
Lines 10499 10512 +13
==========================================
+ Hits 7204 7215 +11
- Misses 2788 2789 +1
- Partials 507 508 +1
Continue to review full report at Codecov.
|
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.
See inline for adapting an existing function to do this
@ncw |
I've found this code does not work well. >>> ascii('\U+10001')
"'\\U00010001'" |
@ncw If there is something I missed. Please let me know! func stringEscape(a py.String) string {
s := string(a)
var out bytes.Buffer
for _, c := range s {
switch {
case c < 0x20:
switch c {
case '\t':
out.WriteString(`\t`)
case '\n':
out.WriteString(`\n`)
case '\r':
out.WriteString(`\r`)
default:
out.WriteRune(c)
}
case c < 0x100:
out.WriteRune(c)
case c < 0x10000:
fmt.Fprintf(&out, "\\u%04x", c)
default:
fmt.Fprintf(&out, "\\U%08x", c)
}
}
return out.String()
} |
LGTM - thank you - please merge :-) |
Implement builtin_ascii