diff options
author | Wim <wim@42.be> | 2018-08-06 21:47:05 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2018-08-06 21:47:05 +0200 |
commit | 51062863a5c34d81e296cf15c61140911037cf3b (patch) | |
tree | 9b5e044672486326c7a0ca8fb26430f37bf4d83c /vendor/github.com/paulrosania/go-charset/cmd/tcs/tcs.go | |
parent | 4fb4b7aa6c02a54db8ad8dd98e4d321396926c0d (diff) | |
download | matterbridge-msglm-51062863a5c34d81e296cf15c61140911037cf3b.tar.gz matterbridge-msglm-51062863a5c34d81e296cf15c61140911037cf3b.tar.bz2 matterbridge-msglm-51062863a5c34d81e296cf15c61140911037cf3b.zip |
Use mod vendor for vendored directory (backwards compatible)
Diffstat (limited to 'vendor/github.com/paulrosania/go-charset/cmd/tcs/tcs.go')
-rw-r--r-- | vendor/github.com/paulrosania/go-charset/cmd/tcs/tcs.go | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/vendor/github.com/paulrosania/go-charset/cmd/tcs/tcs.go b/vendor/github.com/paulrosania/go-charset/cmd/tcs/tcs.go deleted file mode 100644 index 188c2a16..00000000 --- a/vendor/github.com/paulrosania/go-charset/cmd/tcs/tcs.go +++ /dev/null @@ -1,103 +0,0 @@ -package main - -import ( - "bytes" - "flag" - "fmt" - "github.com/paulrosania/go-charset/charset" - _ "github.com/paulrosania/go-charset/charset/iconv" - "io" - "os" - "strings" -) - -var listFlag = flag.Bool("l", false, "list available character sets") -var verboseFlag = flag.Bool("v", false, "list more information") -var fromCharset = flag.String("f", "utf-8", "translate from this character set") -var toCharset = flag.String("t", "utf-8", "translate to this character set") - -func main() { - flag.Usage = func() { - fmt.Fprintf(os.Stderr, "usage: tcs [-l] [-v] [charset]\n") - fmt.Fprintf(os.Stderr, "\ttcs [-f charset] [-t charset] [file]\n") - } - flag.Parse() - if *listFlag { - cs := "" - switch flag.NArg() { - case 1: - cs = flag.Arg(0) - case 0: - default: - flag.Usage() - } - listCharsets(*verboseFlag, cs) - return - } - var f *os.File - switch flag.NArg() { - case 0: - f = os.Stdin - case 1: - var err error - f, err = os.Open(flag.Arg(0)) - if err != nil { - fatalf("cannot open %q: %v", err) - } - } - r, err := charset.NewReader(*fromCharset, f) - if err != nil { - fatalf("cannot translate from %q: %v", *fromCharset, err) - } - w, err := charset.NewWriter(*toCharset, os.Stdout) - if err != nil { - fatalf("cannot translate to %q: ", err) - } - _, err = io.Copy(w, r) - if err != nil { - fatalf("%v", err) - } -} - -func listCharsets(verbose bool, csname string) { - var buf bytes.Buffer - if !verbose { - if csname != "" { - cs := charset.Info(csname) - if cs == nil { - fatalf("no such charset %q", csname) - } - fmt.Fprintf(&buf, "%s %s\n", cs.Name, strings.Join(cs.Aliases, " ")) - } else { - fmt.Fprintf(&buf, "%v\n", strings.Join(charset.Names(), " ")) - } - } else { - var charsets []*charset.Charset - if csname != "" { - cs := charset.Info(csname) - if cs == nil { - fatalf("no such charset %q", csname) - } - charsets = []*charset.Charset{cs} - } else { - for _, name := range charset.Names() { - if cs := charset.Info(name); cs != nil { - charsets = append(charsets, cs) - } - } - } - for _, cs := range charsets { - fmt.Fprintf(&buf, "%s %s\n", cs.Name, strings.Join(cs.Aliases, " ")) - if cs.Desc != "" { - fmt.Fprintf(&buf, "\t%s\n", cs.Desc) - } - } - } - os.Stdout.Write(buf.Bytes()) -} - -func fatalf(f string, a ...interface{}) { - s := fmt.Sprintf(f, a...) - fmt.Fprintf(os.Stderr, "%s\n", s) - os.Exit(2) -} |