nushell / nushell/nushell

Command to look up codepoint from a character

Open
#14,264 21 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

category:enhancement status:needs-triage
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.