MCPcopy Create free account
hub / github.com/francoispqt/gojay / writeStringEscape

Method writeStringEscape

encode_builder.go:38–65  ·  view source on GitHub ↗
(s string)

Source from the content-addressed store, hash-verified

36}
37
38func (enc *Encoder) writeStringEscape(s string) {
39 l := len(s)
40 for i := 0; i < l; i++ {
41 c := s[i]
42 if c >= 0x20 && c != '\\' && c != '"' {
43 enc.writeByte(c)
44 continue
45 }
46 switch c {
47 case '\\', '"':
48 enc.writeTwoBytes('\\', c)
49 case '\n':
50 enc.writeTwoBytes('\\', 'n')
51 case '\f':
52 enc.writeTwoBytes('\\', 'f')
53 case '\b':
54 enc.writeTwoBytes('\\', 'b')
55 case '\r':
56 enc.writeTwoBytes('\\', 'r')
57 case '\t':
58 enc.writeTwoBytes('\\', 't')
59 default:
60 enc.writeString(`\u00`)
61 enc.writeTwoBytes(hex[c>>4], hex[c&0xF])
62 }
63 continue
64 }
65}

Callers 15

Uint64KeyMethod · 0.95
Uint64KeyOmitEmptyMethod · 0.95
Uint64KeyNullEmptyMethod · 0.95
IntKeyMethod · 0.95
IntKeyOmitEmptyMethod · 0.95
IntKeyNullEmptyMethod · 0.95
Int64KeyMethod · 0.95
Int64KeyOmitEmptyMethod · 0.95
Int64KeyNullEmptyMethod · 0.95
AddEmbeddedJSONKeyMethod · 0.95
encodeStringMethod · 0.95

Calls 3

writeByteMethod · 0.95
writeTwoBytesMethod · 0.95
writeStringMethod · 0.95

Tested by

no test coverage detected