Skip to content

Commit e242227

Browse files
committed
Accept hex codepoints starting with %
Easier to copy/paste something from URL-encoded.
1 parent 7218118 commit e242227

3 files changed

Lines changed: 11 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
### unreleased
2+
3+
- Accept hex codepoints starting with a `%` for the `print` command (e.g. `%25`
4+
or `%5C`).
5+
16
### v2.9.0 (2025-12-16)
27

38
- Update to Unicode 17.0.

uni.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ Commands:
9696
print [query] Print characters. The query can be any of the following:
9797
9898
Codepoint Specific codepoint, in number formats:
99-
hexadecimal U+20, U20, 0x20, x20, 20
100-
decimal 0d32
101-
octal 0o40, o40
102-
binary 0b100000
99+
hex U+20, U20, 0x20, x20, 20, %20
100+
decimal 0d32
101+
octal 0o40, o40
102+
binary 0b100000
103103
104104
Range Range of codepoints, as "start-end" or
105105
"start..end", using the same notation as

unidata/codepoint.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ func Find(cp rune) (Codepoint, bool) {
203203
// The input can be as (case-insensitive):
204204
//
205205
// U+F1, U+00F1, UF1, F1 Unicode codepoint notation (hex)
206-
// 0xF1, xF1 Hex number
206+
// 0xF1, xF1, %F1 Hex number
207207
// 0d241 Decimal number
208208
// 0o361, o361 Octal number
209209
// 0b11110001 Binary number
@@ -224,7 +224,7 @@ func FromString(s string) (Codepoint, error) {
224224
s = s[2:]
225225
base = 2
226226

227-
case strings.HasPrefix(s, "X") || strings.HasPrefix(s, "U"):
227+
case strings.HasPrefix(s, "X") || strings.HasPrefix(s, "U") || strings.HasPrefix(s, "%"):
228228
s = s[1:]
229229
case strings.HasPrefix(s, "O"):
230230
s = s[1:]

0 commit comments

Comments
 (0)