What is best way to send emoji to sendInput action? #12093

Closed
opened 2026-01-31 03:06:13 +00:00 by claunia · 7 comments
Owner

Originally created by @krave1986 on GitHub (Jan 16, 2021).

Description of the new feature/enhancement

Open vscode to edit the settings.json file.
Locate "actions" property in json file and add this one:

      {
            "command": {
                "action": "sendInput",
                "input": "\"🚀\""

            },
            "keys": "ctrl+l"
        }

What I need to do to print emoji would be

        {
            "command": {
                "action": "sendInput",
                "input": "\"`u{1F680}\"\r"
            },
            "keys": "ctrl+l"
        }

Is it the best way to set emoji as argument of sendInput action? Or is there any better way to do that?

Originally created by @krave1986 on GitHub (Jan 16, 2021). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> # Description of the new feature/enhancement Open vscode to edit the settings.json file. Locate "actions" property in json file and add this one: ``` { "command": { "action": "sendInput", "input": "\"🚀\"" }, "keys": "ctrl+l" } ``` What I need to do to print emoji would be ``` { "command": { "action": "sendInput", "input": "\"`u{1F680}\"\r" }, "keys": "ctrl+l" } ``` Is it the best way to set emoji as argument of sendInput action? Or is there any better way to do that?
Author
Owner

@DHowett commented on GitHub (Jan 17, 2021):

The correct way to input an emoji depends on what you are doing. The first one works fine for sending the rocket emoji 🚀 with " on either side. The second one works fine for sending the character code of the rocket emoji in PowerShell's unicode escape format also wrapped in ". Both of those are different from sending the rocket emoji on its own.

What are you trying to do, and what's happening?

Is this the same report as #8808?

@DHowett commented on GitHub (Jan 17, 2021): The correct way to input an emoji depends on what you are doing. The first one works fine for sending the rocket emoji 🚀 with `"` on either side. The second one works fine for sending the character code of the rocket emoji _in PowerShell's unicode escape format_ also wrapped in `"`. Both of those are different from sending the rocket emoji on its own. What are you trying to do, and what's happening? Is this the same report as #8808?
Author
Owner

@krave1986 commented on GitHub (Jan 17, 2021):

For this issue here, I would like to edit settings.json mostly within vscode which supports emoji well. So as to my use case, I just want to print emoji by pressing a shortcut key. I thought sendInput action could be my solution. While doing this, I found that I am not able to simply copy 🚀 and paste it into vscode to finish the job. Instead, I have to convert 🚀 into, like you mentioned, PowerShell's unicode escape format `u{1F680} and wrap it with " to make it work.

Is it possible to get rid of the convertion step?

For #8808 , I want copy 🚀 and paste it into terminal.
What I desire is:
image

What I got is:
image

@krave1986 commented on GitHub (Jan 17, 2021): For this issue here, I would like to edit settings.json mostly within vscode which supports emoji well. So as to my use case, I just want to print emoji by pressing a shortcut key. I thought `sendInput` action could be my solution. While doing this, I found that I am not able to simply copy 🚀 and paste it into vscode to finish the job. Instead, I have to convert 🚀 into, like you mentioned, PowerShell's unicode escape format `` `u{1F680}`` and wrap it with `"` to make it work. Is it possible to get rid of the _convertion_ step? For #8808 , I want copy 🚀 and paste it into terminal. What I desire is: ![image](https://user-images.githubusercontent.com/16416541/104836244-89f29c00-58e7-11eb-87c5-0ce05ade88fe.png) What I got is: ![image](https://user-images.githubusercontent.com/16416541/104836266-b5758680-58e7-11eb-87b5-495d9bfa0f7f.png)
Author
Owner

@zadjii-msft commented on GitHub (Jan 19, 2021):

Oh so the real problem here is that fundamentally, the console doesn't support emoji input currently. See #190, #1503. So even if the Terminal knows how to handle emoji correctly, the underlying console is going to mangle them before powershell/cmd has a chance to read them and display them.

/dup #190
/dup #1503

@zadjii-msft commented on GitHub (Jan 19, 2021): Oh so the real problem here is that _fundamentally_, the console doesn't support emoji input currently. See #190, #1503. So even if the Terminal knows how to handle emoji correctly, the underlying console is going to mangle them before powershell/cmd has a chance to read them and display them. /dup #190 /dup #1503
Author
Owner

@ghost commented on GitHub (Jan 19, 2021):

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@ghost commented on GitHub (Jan 19, 2021): Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!
Author
Owner

@krave1986 commented on GitHub (Jan 19, 2021):

Hi, @zadjii-msft , could you please shed some light on my issue about sendInput ?

For this issue here, I would like to edit settings.json mostly within vscode which supports emoji well. So as to my use case, I just want to print emoji by pressing a shortcut key. I thought sendInput action could be my solution. While doing this, I found that I am not able to simply copy 🚀 and paste it into vscode to finish the job. Instead, I have to convert 🚀 into, like you mentioned, PowerShell's unicode escape format `u{1F680} and wrap it with " to make it work.

Is it possible to get rid of the convertion step?

Is there an easy way to use emoji in settings.json as input for sendInput action?

@krave1986 commented on GitHub (Jan 19, 2021): Hi, @zadjii-msft , could you please shed some light on my issue about `sendInput` ? > For this issue here, I would like to edit settings.json mostly within vscode which supports emoji well. So as to my use case, I just want to print emoji by pressing a shortcut key. I thought sendInput action could be my solution. While doing this, I found that I am not able to simply copy 🚀 and paste it into vscode to finish the job. Instead, I have to convert 🚀 into, like you mentioned, PowerShell's unicode escape format `u{1F680} and wrap it with " to make it work. > > Is it possible to get rid of the convertion step? Is there an easy way to use emoji in settings.json as input for `sendInput` action?
Author
Owner

@zadjii-msft commented on GitHub (Jan 19, 2021):

Not really - at the end of the day, the console is going to mangle the emoji in the input line. So you should be able to just have emoji directly in the file. However, that won't work today, because of the previously mentioned bugs. The console (and Terminal) can handle emoji output perfectly well, but emoji input doesn't work nearly as well.

@zadjii-msft commented on GitHub (Jan 19, 2021): Not really - at the end of the day, the console is going to mangle the emoji in the input line. So you _should_ be able to just have emoji directly in the file. However, that won't work today, because of the previously mentioned bugs. The console (and Terminal) can handle emoji _output_ perfectly well, but emoji _input_ doesn't work nearly as well.
Author
Owner

@krave1986 commented on GitHub (Jan 20, 2021):

Got it. Thanks for the clarification.

@krave1986 commented on GitHub (Jan 20, 2021): Got it. Thanks for the clarification.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#12093