File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,8 +26,8 @@ func Decode(code string) (CodeArea, error) {
2626 }
2727 // Strip out separator character, padding characters and convert to upper
2828 // case.
29- codeBytes : = StripCode (code )
30- codeLen := len (codeBytes )
29+ code = StripCode (code )
30+ codeLen := len (code )
3131 // lat and lng build up the integer values.
3232 var lat int64
3333 var lng int64
@@ -42,8 +42,8 @@ func Decode(code string) (CodeArea, error) {
4242 lng *= encBase
4343 height *= encBase
4444 if i < codeLen {
45- lat += alphabetPosition [codeBytes [i ]]
46- lng += alphabetPosition [codeBytes [i + 1 ]]
45+ lat += alphabetPosition [code [i ]]
46+ lng += alphabetPosition [code [i + 1 ]]
4747 height = 1
4848 }
4949 }
@@ -56,7 +56,7 @@ func Decode(code string) (CodeArea, error) {
5656 lng *= gridCols
5757 width *= gridCols
5858 if i < codeLen {
59- dval := alphabetPosition [codeBytes [i ]]
59+ dval := alphabetPosition [code [i ]]
6060 lat += dval / gridCols
6161 lng += dval % gridCols
6262 height = 1
Original file line number Diff line number Diff line change @@ -189,6 +189,13 @@ func CheckFull(code string) error {
189189 return nil
190190}
191191
192+ func upper (b byte ) byte {
193+ if 'c' <= b && b <= 'x' {
194+ return b + 'C' - 'c'
195+ }
196+ return b
197+ }
198+
192199// StripCode strips the padding and separator characters from the code.
193200//
194201// The code is truncated to the first 15 digits, as Decode won't use more,
@@ -200,7 +207,7 @@ func StripCode(code string) string {
200207 if r == Separator || r == Padding {
201208 continue
202209 }
203- result [pos ] = byte (r )
210+ result [pos ] = upper ( byte (r ) )
204211 pos ++
205212 if pos >= maxCodeLen {
206213 break
You can’t perform that action at this time.
0 commit comments