Skip to content

Commit

Permalink
Convert int to string using rune()
Browse files Browse the repository at this point in the history
See golang/go#32479

Signed-off-by: Robert-André Mauchin <zebob.m@gmail.com>
  • Loading branch information
eclipseo committed Aug 8, 2020
1 parent b0a198c commit 49cf065
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"io"
"log"
"os"
"unicode"

"modernc.org/lex"
)
Expand Down Expand Up @@ -56,8 +57,12 @@ func (r *noRender) wprintf(s string, args ...interface{}) (n int, err error) {
func q(c uint32) string {
switch c {
default:
s := fmt.Sprintf("%q", string(c))
return "'" + s[1:len(s)-1] + "'"
r := rune(c)
if r >= 0 && r <= unicode.MaxRune {
s := fmt.Sprintf("%q", string(r))
return "'" + s[1:len(s)-1] + "'"
}
return ""
case '\'':
return "'\\''"
case '"':
Expand Down

0 comments on commit 49cf065

Please sign in to comment.