Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 31 additions & 7 deletions unisub/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,34 @@ import (
)

func main() {
flag.Parse()

char := flag.Arg(0)
var silent bool
flag.BoolVar(&silent, "silent", false, "enable silnet mode")
var urlEncodeOnly bool
flag.BoolVar(&urlEncodeOnly, "encode", false, "display only url econded string")

flag.Parse()

if flag.NArg() < 1 {
fmt.Println("usage: unisub <char>")
return
}

subs, ok := translations[rune(char[0])]

char := flag.Arg(0)
subs, ok := translations[rune(char[0])]
if !ok {
fmt.Println("no substitutions found")
return
}

for _, s := range subs {
fmt.Printf("fallback: %c %U %s\n", s, s, url.QueryEscape(string(s)))
if silent {
fmt.Printf("%c\n", s)
} else if urlEncodeOnly {
fmt.Printf("%s\n", url.QueryEscape(string(s)))
} else {
fmt.Printf("fallback: %c %U %s\n", s, s, url.QueryEscape(string(s)))
}
}

for cp := 1; cp < 0x10FFFF; cp++ {
Expand All @@ -33,11 +45,23 @@ func main() {
}

if strings.ToLower(string(s)) == char {
fmt.Printf("toLower: %c %U %s\n", s, s, url.QueryEscape(string(s)))
if silent {
fmt.Printf("%c\n", s)
} else if urlEncodeOnly {
fmt.Printf("%s\n", url.QueryEscape(string(s)))
} else {
fmt.Printf("toLower: %c %U %s\n", s, s, url.QueryEscape(string(s)))
}
}

if strings.ToUpper(string(s)) == char {
fmt.Printf("toUpper: %c %U %s\n", s, s, url.QueryEscape(string(s)))
if silent {
fmt.Printf("%c\n", s)
} else if urlEncodeOnly {
fmt.Printf("%s\n", url.QueryEscape(string(s)))
} else {
fmt.Printf("toUpper: %c %U %s\n", s, s, url.QueryEscape(string(s)))
}
}
}
}