File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99
1010## To Do
1111
12- - [ ] ` anyascii ` : converts to ASCII using [ anyascii] ( https://github.com/anyascii/anyascii )
12+ - [x ] ` asciify ` : converts to ASCII using [ anyascii] ( https://github.com/anyascii/anyascii )
1313- [x] ` asciitable ` : prints out an table of ASCII characters
1414- [ ] ` bytecount ` : counts the number of occurrences of each byte
1515- [x] ` certinfo ` : print info about an x509 (aka SSL/HTTPS) certificate
Original file line number Diff line number Diff line change 1+ package main
2+
3+ import (
4+ "fmt"
5+ "os"
6+
7+ anyascii "github.com/anyascii/go"
8+ "golang.org/x/text/encoding/charmap"
9+ )
10+
11+ func main () {
12+
13+ input , err := os .ReadFile ("/dev/stdin" )
14+ if err != nil {
15+ fmt .Fprintln (os .Stderr , "Error reading stdin:" , err )
16+ os .Exit (1 )
17+ }
18+
19+ // LATER: option to use a different code page
20+ decoder := charmap .CodePage437 .NewDecoder ()
21+
22+ // LATER: option to skip decoding (in case input is already UTF-8)
23+ utf8 , err := decoder .Bytes (input )
24+ if err != nil {
25+ fmt .Fprintln (os .Stderr , "ERROR: unable to decode input: " , err )
26+ os .Exit (1 )
27+ }
28+
29+ output := anyascii .Transliterate (string (utf8 ))
30+ fmt .Print (output )
31+ }
Original file line number Diff line number Diff line change 55require golang.org/x/crypto v0.38.0
66
77require (
8+ github.com/anyascii/go v0.3.2 // indirect
89 github.com/fatih/color v1.15.0 // indirect
910 github.com/mattn/go-colorable v0.1.13 // indirect
1011 github.com/mattn/go-isatty v0.0.19 // indirect
Original file line number Diff line number Diff line change 1+ github.com/anyascii/go v0.3.2 h1:87uFISteh7vwofK02srrPKtAvG6Wx7ozRjNh8uhfa7w =
2+ github.com/anyascii/go v0.3.2 /go.mod h1:HDvbMmSpqJyIe+xtSkHmAYTjc8PzvO3l1Jmgx/IFUPs =
13github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs =
24github.com/fatih/color v1.15.0 /go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw =
35github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA =
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ set -o errexit
77set -o nounset
88set -o pipefail
99
10- go build -o ./dist/asciitable ./cmd/asciitable
10+ CMD= " ${1 :- asciify} "
1111
12- ./dist/asciitable
12+ go build -o " ./dist/${CMD} " " ./cmd/${CMD} "
13+
14+ ./dist/${CMD}
You can’t perform that action at this time.
0 commit comments