|
|
|
@ -11,9 +11,10 @@ import (
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
// Define the shift and hex flags
|
|
|
|
|
// Define the shift, hex, and space flags
|
|
|
|
|
shift := flag.Int("s", 0, "Shift value for alphabet positions (can be negative)")
|
|
|
|
|
useHex := flag.Bool("x", false, "Encode numbers in hexadecimal")
|
|
|
|
|
encodeSpaces := flag.Bool("S", false, "Encode spaces as '00'")
|
|
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
|
|
// Check if input is being piped or passed as an argument
|
|
|
|
@ -58,6 +59,13 @@ func main() {
|
|
|
|
|
} else if unicode.IsDigit(char) {
|
|
|
|
|
// Collect digits to process as a whole number
|
|
|
|
|
currentNumber += string(char)
|
|
|
|
|
} else if char == ' ' && *encodeSpaces {
|
|
|
|
|
// Encode space as '00' if the -S flag is set
|
|
|
|
|
if currentNumber != "" {
|
|
|
|
|
appendNumber(&result, currentNumber, *useHex)
|
|
|
|
|
currentNumber = ""
|
|
|
|
|
}
|
|
|
|
|
result = append(result, "00")
|
|
|
|
|
} else {
|
|
|
|
|
// If there was a number being processed and now a non-digit/non-letter appears, append it
|
|
|
|
|
if currentNumber != "" {
|
|
|
|
|