Command to look up codepoint from a character
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 40.5k
- Forks
- 2.3k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 85
Description
Related problem
Related: #14174 - The seq char command doesn't work well for non-alpha characters.
Rather than fixing seq char, what if we deprecate it (or move a new version to the Standard Library.
The problem at the moment is that (AFAICT) we have no way to get the codepoint for a character in order to know where it lies in the ASCII (or Unicode) table.
Describe the solution you'd like
Either a new command or an extension to the char command to be able to look up the codepoint for a character. For example:
let start = (char --int-from-char 'A')
$start
# => 65
let end = (char --int-from-char 'D')
$end
# => 68
# Replace the `seq char` with:
$start..$end | each {char --integer $in}
# => ╭───┬───╮
# => │ 0 │ A │
# => │ 1 │ B │
# => │ 2 │ C │
# => │ 3 │ D │
# => ╰───┴───╯
Since we don't have a "character" type, the string passed to char --int-from-char should be only one grapheme cluster in length or it should error, I think.
Shouldn't be limited to ASCII, but all Unicode characters should return their codepoint. For example:
char --int-from-char '✔'
# => 10004
Describe alternatives you've considered
No response
Additional context and details
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the existing char command and seq char behavior, then read related issue #14174 for context. Done should mean a command or char extension accepts one grapheme cluster and returns its Unicode codepoint, including non-ASCII characters, with invalid input handled as specified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100