protocol/aprs: refactored
This commit is contained in:
@@ -2,12 +2,14 @@ package aprs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
)
|
||||
|
||||
func base91Decode(s string) (n int, err error) {
|
||||
for i, l := 0, len(s); i < l; i++ {
|
||||
c := s[i]
|
||||
if c < 33 || c > 122 {
|
||||
// panic(fmt.Sprintf("aprs: invalid base-91 encoding char %q (%d)", c, c))
|
||||
return 0, fmt.Errorf("aprs: invalid base-91 encoding char %q (%d)", c, c)
|
||||
}
|
||||
|
||||
@@ -17,14 +19,13 @@ func base91Decode(s string) (n int, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
/*
|
||||
func base91Encode(n int) string {
|
||||
var s []string
|
||||
for n > 0 {
|
||||
c := n % 91
|
||||
func base91Encode(b []byte, n int) {
|
||||
i := 0
|
||||
for n > 1 {
|
||||
x := n % 91
|
||||
n /= 91
|
||||
s = append([]string{string(byte(c) + 33)}, s...)
|
||||
b[i] = byte(x) + 33
|
||||
i++
|
||||
}
|
||||
return strings.Join(s, "")
|
||||
slices.Reverse(b[:i])
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user