Skip to content

Commit

Permalink
"uni p U+2042-U+2044" works like "uni p U+2042..U+2044"
Browse files Browse the repository at this point in the history
  • Loading branch information
arp242 committed Feb 5, 2020
1 parent fd05e6a commit bf15098
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 0 additions & 1 deletion TODO
@@ -1,5 +1,4 @@
- uni p < a → doesn't split on spaces (should it? 🤔)
- uni p 2000-2002 → should just work
- Add -output option to control output format.
- Add -format option to configure columns.
- Add option to search and/or print by "other keywords" from CLDR. Maybe also
Expand Down
11 changes: 8 additions & 3 deletions uni.go
Expand Up @@ -476,9 +476,14 @@ func print(args []string, quiet, raw bool) error {
}

// U2042, U+2042, U+2042..U+2050, 2042..2050, 0x2041, etc.
s := strings.Split(canon, "..")
if len(s) == 1 {
s = append(s, s[0])
var s []string
switch {
case strings.Contains(canon, ".."):
s = strings.SplitN(canon, "..", 2)
case strings.Contains(canon, "-"):
s = strings.SplitN(canon, "-", 2)
default:
s = []string{canon, canon}
}
start, err1 := unidata.ToCodepoint(s[0])
end, err2 := unidata.ToCodepoint(s[1])
Expand Down
1 change: 1 addition & 0 deletions uni_test.go
Expand Up @@ -115,6 +115,7 @@ func TestPrint(t *testing.T) {
{[]string{"-q", "p", "2042..U+2044"}, "ASTERISM", 3, -1},
{[]string{"-q", "p", "0x2042..0o20104"}, "ASTERISM", 3, -1},
{[]string{"-q", "p", "0b10000001000010..0o20104"}, "ASTERISM", 3, -1},
{[]string{"-q", "p", "0b10000001000010-0o20104"}, "ASTERISM", 3, -1},
{[]string{"p", "9999999999"}, `CODEPOINT NOT IN UNICODE`, 2, -1},

{[]string{"p", ""}, `unknown identifier: ""`, 1, 1},
Expand Down

0 comments on commit bf15098

Please sign in to comment.