Support the Alt+X keybinding to toggle between an Unicode character and its hex encoding #17909

Open
opened 2026-01-31 05:58:08 +00:00 by claunia · 4 comments
Owner

Originally created by @lhecker on GitHub (Jul 12, 2022).

Description of the new feature/enhancement

As suggested by @MurraySargent:
A number of Microsoft applications (e.g. Word, Notepad) allow you to press Alt+X to switch between a Unicode character and its hex encoding. For instance you can enter a hex number like "222b", press Alt+X and get "∫". Pressing Alt+X again, will turn it back into "222b".

This appears to be a useful alternative to the old Alt+Numpad input, which fails to work on keyboards without numpad. However I'm unsure whether implementing this feature is trivially possible without running into edge cases (it requires us to erase characters previously sent to the shell).

Proposed technical implementation details (optional)

RichEdit's CTxtRange::HexToUnicode().

Originally created by @lhecker on GitHub (Jul 12, 2022). # Description of the new feature/enhancement As suggested by @MurraySargent: A number of Microsoft applications (e.g. Word, Notepad) allow you to press Alt+X to switch between a Unicode character and its hex encoding. For instance you can enter a hex number like "222b", press Alt+X and get "∫". Pressing Alt+X again, will turn it back into "222b". This appears to be a useful alternative to the old Alt+Numpad input, which fails to work on keyboards without numpad. However I'm unsure whether implementing this feature is trivially possible without running into edge cases (it requires us to erase characters previously sent to the shell). # Proposed technical implementation details (optional) RichEdit's `CTxtRange::HexToUnicode()`.
claunia added the Issue-FeatureArea-InputProduct-TerminalArea-i18n labels 2026-01-31 05:58:09 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Jul 12, 2022):

Huh, I never knew that. TIL.

That being said, it's definitely not trivial for us, for the reason mentioned. What about for something like vim, or emacs? I suppose we could send backspaces for the number of characters we're expecting to replace. Well, I suppose that might kinda work.

I imagine this works (for us) as such:

  • when the action / keybinding is triggered,
    • scan the characters preceeding the cursor in the buffer
    • if they're a hex digit
      • send backspaces, followed by the unicode char(s)
    • (and the reverse for unicode)

it'd be weird for something like vim, outside of edit mode - the cursor would be in the middle of the buffer, after a "∫", you'd press the keybinding, and we'd yeet ^h222b at vim and just hope for the best

@zadjii-msft commented on GitHub (Jul 12, 2022): Huh, I never knew that. TIL. That being said, it's definitely not trivial for us, for the reason mentioned. What about for something like vim, or emacs? I suppose we could send backspaces for the number of characters we're expecting to replace. Well, I suppose that might kinda work. I imagine this works (for us) as such: * when the action / keybinding is triggered, * scan the characters preceeding the cursor in the buffer * if they're a hex digit * send backspaces, followed by the unicode char(s) * (and the reverse for unicode) it'd be weird for something like vim, outside of edit mode - the cursor would be in the middle of the buffer, after a "∫", you'd press the keybinding, and we'd yeet `^h222b` at vim and just _hope for the best_
Author
Owner

@DHowett commented on GitHub (Jul 12, 2022):

I'm not necessarily in support of this. I'd rather it be a different input mode, ala vim's ^V u (Verbatim input, Unicode).

@DHowett commented on GitHub (Jul 12, 2022): I'm not necessarily in support of this. I'd rather it be a different input mode, ala vim's `^V u` (Verbatim input, Unicode).
Author
Owner

@zadjii-msft commented on GitHub (Aug 19, 2022):

I'm gonna yank triage off this and stick it in the icebox. It's an idea, for sure, but one that needs more massaging.

@zadjii-msft commented on GitHub (Aug 19, 2022): I'm gonna yank triage off this and stick it in the icebox. It's an idea, for sure, but one that needs more massaging.
Author
Owner

@sba923 commented on GitHub (Mar 10, 2024):

If you're using PowerShell, check this out: https://github.com/PowerShell/PSReadLine/issues/3578#issuecomment-1987149796

@sba923 commented on GitHub (Mar 10, 2024): If you're using PowerShell, check this out: https://github.com/PowerShell/PSReadLine/issues/3578#issuecomment-1987149796
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#17909