You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Several strings in win\pty.cc are converting wide strings to narrow strings #104
I'm not 100% sure, but I think the initializer of msg_ converts the wide string to a narrow string by truncating each wchar_t value to a char. It will only be correct for ASCII characters. I'm guessing node.js and/or v8 want UTF-8 strings? Standard C++ has a way to do that conversion (as of C++11, I think -- I'm thinking of std::codecvt), and maybe node.js / v8 also does? Windows has C-style APIs to do the conversion.
I think the pattern already existed in the code, so it's probably not necessary to fix it in this PR? e.g. see shellpath_'s initializer.
Daniel Imms (@Tyriar) Imho the conversion is not needed at all since Windows uses internally a type of UTF-16 for wchar_t and so does Javascript (not sure though if they agree on all parts under all circumstances as there are several flavors of UTF-16).
And for testing - hmm, to see if all wchar_ts get correctly mapped and understood in JS maybe you can use the codePointAt() method in JS and compare the values with the codepoint number from C++.
Btw the new for (xy in s) and the Array.from(s) in JS act on codepoints and not on charcodes anymore, which is helpful to get an iteration on those running. String.length still maps to the charcode length though.
Closing as out of scope, the winpty support will likely be ripped out in the future as it's on life support at this point. When we move to conpty dll by default (microsoft/vscode#224488) we can potentially even remove the Windows conpty integration too.
Activity
jerch commentedon Jul 11, 2017
Daniel Imms (@Tyriar) Imho the conversion is not needed at all since Windows uses internally a type of UTF-16 for
wchar_tand so does Javascript (not sure though if they agree on all parts under all circumstances as there are several flavors of UTF-16).Untested:
Tyriar commentedon Jul 11, 2017
jerch I did something like that but I wasn't sure what the best way to test it was.
jerch commentedon Jul 12, 2017
Daniel Imms (@Tyriar) The official docs state the following:
V8 developer doc mentions UTF-16 for method
v8::String::NewFromTwoByte(http://bespin.cz/~ondras/html/classv8_1_1String.html#a876615eb027092a6a71a4e7d69b82d00) - seems to be safe to just cast thewchar_t*touint16_t*.And for testing - hmm, to see if all
wchar_ts get correctly mapped and understood in JS maybe you can use thecodePointAt()method in JS and compare the values with the codepoint number from C++.Btw the new
for (xy in s)and theArray.from(s)in JS act on codepoints and not on charcodes anymore, which is helpful to get an iteration on those running.String.lengthstill maps to the charcode length though.Tyriar commentedon Dec 19, 2025
Closing as out of scope, the winpty support will likely be ripped out in the future as it's on life support at this point. When we move to conpty dll by default (microsoft/vscode#224488) we can potentially even remove the Windows conpty integration too.
cc Anthony Kim (@anthonykim1)