MCPcopy Index your code
hub / github.com/skip2/go-qrcode / encodeAlphanumericCharacter

Function encodeAlphanumericCharacter

encoder.go:453–486  ·  view source on GitHub ↗

encodeAlphanumericChar returns the QR Code encoded value of v. v must be a QR Code defined alphanumeric character: 0-9, A-Z, SP, $%*+-./ or :. The characters are mapped to values in the range 0-44 respectively.

(v byte)

Source from the content-addressed store, hash-verified

451// v must be a QR Code defined alphanumeric character: 0-9, A-Z, SP, $%*+-./ or
452// :. The characters are mapped to values in the range 0-44 respectively.
453func encodeAlphanumericCharacter(v byte) uint32 {
454 c := uint32(v)
455
456 switch {
457 case c >= '0' && c <= '9':
458 // 0-9 encoded as 0-9.
459 return c - '0'
460 case c >= 'A' && c <= 'Z':
461 // A-Z encoded as 10-35.
462 return c - 'A' + 10
463 case c == ' ':
464 return 36
465 case c == '$':
466 return 37
467 case c == '%':
468 return 38
469 case c == '*':
470 return 39
471 case c == '+':
472 return 40
473 case c == '-':
474 return 41
475 case c == '.':
476 return 42
477 case c == '/':
478 return 43
479 case c == ':':
480 return 44
481 default:
482 log.Panicf("encodeAlphanumericCharacter() with non alphanumeric char %v.", v)
483 }
484
485 return 0
486}

Callers 1

encodeDataRawMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…