(s string)
| 36 | } |
| 37 | |
| 38 | func (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 | } |
no test coverage detected