MCPcopy Create free account
hub / github.com/bcicen/jstream / u4

Method u4

decoder.go:320–338  ·  view source on GitHub ↗

u4 reads four bytes following a \u escape

()

Source from the content-addressed store, hash-verified

318
319// u4 reads four bytes following a \u escape
320func (d *Decoder) u4() rune {
321 // logic taken from:
322 // github.com/buger/jsonparser/blob/master/escape.go#L20
323 var h [4]int
324 for i := 0; i < 4; i++ {
325 c := d.next()
326 switch {
327 case c >= '0' && c <= '9':
328 h[i] = int(c - '0')
329 case c >= 'A' && c <= 'F':
330 h[i] = int(c - 'A' + 10)
331 case c >= 'a' && c <= 'f':
332 h[i] = int(c - 'a' + 10)
333 default:
334 return -1
335 }
336 }
337 return rune(h[0]<<12 + h[1]<<8 + h[2]<<4 + h[3])
338}
339
340// number called by `any` after reading number between 0 to 9
341func (d *Decoder) number() (float64, error) {

Callers 1

stringMethod · 0.95

Calls 1

nextMethod · 0.80

Tested by

no test coverage detected