8000 json/encoding: form feed encoded as \u000c instead of \f · Issue #64346 · golang/go · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

json/encoding: form feed encoded as \u000c instead of \f #64346

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

Closed
1 task done
ionous opened this issue Nov 22, 2023 · 1 comment
Closed
1 task done

json/encoding: form feed encoded as \u000c instead of \f #64346

ionous opened this issue Nov 22, 2023 · 1 comment

Comments

@ionous
Copy link
ionous commented Nov 22, 2023

Go version

go version go1.21.4 darwin/amd64

Reproducibility

  • Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/Users/ionous/Library/Caches/go-build'
GOENV='/Users/ionous/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/ionous/Dev/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/ionous/Dev/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_amd64'
GOVCS=''
GOVERSION='go1.21.4'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/ionous/Dev/GitHub/tell/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/tv/ch5z1bgs21z1ft04rdk0kk400000gn/T/go-build41269137=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

formFeed:= "\f" 
fmt.Println(formFeed[0]== 0xc)
//
a, _ := json.MarshalIndent(formFeed, "", " ")
fmt.Println(string(a))
fmt.Println(strconv.Quote(formFeed))
fmt.Printf("%q", formFeed)
//
// prints: true, "\u000c", "\f", "\f"

https://play.golang.com/p/vbRfDhCj4DX

What did you expect to see?

i expected to see "\f" ( or maybe something in the documentation on what it escapes, and why. )

json supports escapes using: 'b', 'f', 'n', 'r', 't' -- but while appendString() in src/encoding/json/encode.go generates '\b', '\n', '\r', and '\t' -- it doesn't have handling for '\f'.

package fmt, and package strconv both generate "\f" when quoting 0xc.

What did you see instead?

marshal generates \u000c which -- while perfectly functional -- is unexpected

@dsnet
Copy link
Member
dsnet commented Nov 23, 2023

This has been fixed at HEAD in https://go.dev/cl/521675.

flyn-org added a commit to flyn-org/chroma that referenced this issue Feb 14, 2024
Newer versions of Go emit '\f' rather than "\u000c" for formfeeds. This
patch adjusts the expected values for the lexers tests to match.

Fixes: alecthomas#927

See also: golang/go#64346 for the change to
Go.

Signed-off-by: W. Michael Petullo <mike@flyn.org>
alecthomas pushed a commit to alecthomas/chroma that referenced this issue Feb 14, 2024
Newer versions of Go emit '\f' rather than "\u000c" for formfeeds. This
patch adjusts the expected values for the lexers tests to match.

Fixes: #927

See also: golang/go#64346 for the change to
Go.

Signed-off-by: W. Michael Petullo <mike@flyn.org>
@golang golang locked and limited conversation to collaborators Nov 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants
0