builtin: Implement builtin_ascii#66
Conversation
|
@ncw |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #66 +/- ##
==========================================
+ Coverage 68.45% 68.63% +0.18%
==========================================
Files 59 59
Lines 10495 10512 +17
==========================================
+ Hits 7184 7215 +31
+ Misses 2804 2789 -15
- Partials 507 508 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ncw
left a comment
There was a problem hiding this comment.
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