microsoft / terminal

The new Windows Terminal and the original Windows console host, all in the same place!
MIT License
95.63k stars 8.32k forks source link

Same input with different results in terminal and cmd.exe #6353

Open jnkb opened 4 years ago

jnkb commented 4 years ago

Environment

Windows build number: Microsoft Windows Pro [Version 10.0.18363.836] x64
Windows Terminal version (if applicable): 1.0.1401.0

Any other software?
stripe cli

Steps to reproduce

Download Stripe CLI (https://github.com/stripe/stripe-cli/releases/tag/v1.4.1) after "stripe login" (not sure if needed, i was already logged in) using the command "stripe listen --forward-to https://localhost:44391/api/StripeWebHooks" works on cmd.exe, but not in terminal

Expected behavior

should work as in cmd.exe

Actual behavior

output "unknown flag: --forward-to https://localhost:44391/api/StripeWebHooks"

Screenshot with outputs: image

zadjii-msft commented 4 years ago

Well that just doesn't make any sense at all. I have no idea why that wouldn't work. Do other stripe CLI functions work in the Windows Terminal?

If you have WSL installed, could you try running the following for me?

  1. Open cmd.exe (not in the Windows Terminal)
  2. run wsl in that legacy console window
  3. run cmd.exe from within wsl.
  4. try running your command (stripe listen --forward-to ...) again in this window.

This might help narrow the problem down to Conpty vs the entire Windows Terminal.

jnkb commented 4 years ago

Same Problem in the wls cmd:

image

I just found out that it seems to be an encoding problem. Typing it in manually, it works. Copy & Paste does not work depending on the source.

Try copy & paste from the txt:

terminal_issue_6353.txt

Below the byte arrays of the different inputs. The space after forward-to is different: 32 vs. 194,160. Don't know how this happend.

[...]
n    110    110
     32    32
-    45    45
-    45    45
f    102    102
o    111    111
r    114    114
w    119    119
a    97    97
r    114    114
d    100    100
-    45    45
t    116    116
o    111    111
      32    194
h    104    160
t    116    104
t    116    116
p    112    116
s    115    112
:    58    115
/    47    58
/    47    47
l    108    47
o    111    108
c    99    111
a    97    99
l    108    97
h    104    108
o    111    104
s    115    111
t    116    115

created with with

var working = "stripe listen --forward-to https://localhost:44391/api/StripeWebHooks";
var notWorking = "stripe listen --forward-to https://localhost:44391/api/StripeWebHooks";
var bytesW = Encoding.UTF8.GetBytes(working);
var bytesNW = Encoding.UTF8.GetBytes(notWorking);
for (int i = 0; i < working.Length; i++)
{
    Console.WriteLine(working[i] + "\t\t" + bytesW[i] + "\t\t" + bytesNW[i]);
}
zadjii-msft commented 4 years ago

Oh, excellent work with that!

The 160 is probably a &nbsp, IIRC there's some conhost code that just translates those on paste.

The 194 though, no idea what that's doing in there...

eryksun commented 4 years ago

The 160 is probably a &nbsp, IIRC there's some conhost code that just translates those on paste.

The 194 though, no idea what that's doing in there...

194 is 0xC2, and "\xc2\xa0" is the UTF-8 encoding of a non-breaking space, U+00A0.

DHowett commented 4 years ago

https://github.com/microsoft/terminal/blob/bc60e6a57fb48ad6aa91ae64d478d324f5dc80f4/src/interactivity/win32/Clipboard.cpp#L347-L369

Indeed!