Skip to content

Commit ea66b59

Browse files
authored
Merge pull request #381 from daviwil/fix-543
Fix integrated console input and output of Unicode characters
2 parents 7e6acf9 + 5d0fde3 commit ea66b59

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

src/PowerShellEditorServices/Console/ConsoleReadLine.cs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,6 @@ public async Task<SecureString> ReadSecureLine(CancellationToken cancellationTok
6767
// Break to return the completed string
6868
break;
6969
}
70-
if ((keyInfo.Modifiers & ConsoleModifiers.Alt) == ConsoleModifiers.Alt)
71-
{
72-
continue;
73-
}
74-
if ((keyInfo.Modifiers & ConsoleModifiers.Control) == ConsoleModifiers.Control)
75-
{
76-
continue;
77-
}
7870
if (keyInfo.Key == ConsoleKey.Tab)
7971
{
8072
continue;
@@ -178,13 +170,7 @@ private async Task<string> ReadLine(bool isCommandLine, CancellationToken cancel
178170
consoleWidth,
179171
currentCursorIndex);
180172

181-
if ((keyInfo.Modifiers & ConsoleModifiers.Alt) == ConsoleModifiers.Alt ||
182-
(keyInfo.Modifiers & ConsoleModifiers.Control) == ConsoleModifiers.Control)
183-
{
184-
// Ignore any Ctrl or Alt key combinations
185-
continue;
186-
}
187-
else if (keyInfo.Key == ConsoleKey.Tab && isCommandLine)
173+
if (keyInfo.Key == ConsoleKey.Tab && isCommandLine)
188174
{
189175
if (currentCompletion == null)
190176
{

src/PowerShellEditorServices/Session/SessionPSHostUserInterface.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ internal IConsoleHost ConsoleHost
5151
/// </summary>
5252
public ConsoleServicePSHostUserInterface(bool enableConsoleRepl)
5353
{
54+
if (enableConsoleRepl)
55+
{
56+
// Set the output encoding to Unicode so that all
57+
// Unicode characters are written correctly
58+
System.Console.OutputEncoding = System.Text.Encoding.Unicode;
59+
}
60+
5461
this.rawUserInterface =
5562
enableConsoleRepl
5663
? (PSHostRawUserInterface)new ConsoleServicePSHostRawUserInterface()

0 commit comments

Comments
 (0)