-1

I am using a command(powershell qwinsta) on windows os which returns active sessions. The output contains chinese characters(for username). I have to verify that chinese username. But how can I handle that chinese username? If I write the output to console it is displaying the question marks, if I redirect the output(result) to to text file, then also it is writing question marks in to the file (for chinese characters). How to handle this?

user1423015
  • 413
  • 1
  • 3
  • 9

1 Answers1

0

One option is to change the language used for non-Unicode programs to Chinese. On Windows 7, go to: Control Panel, Region and Language, Administrative, Change system locale and change it to an appropriate Chinese setting. Reboot, and the console will support Chinese characters.

Another option is to redirect the output to a file in Powershell, which writes the file in UTF-16:

C:\>powershell
Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.

PS C:\> qwinsta > out.txt
PS C:\> notepad out.txt
Mark Tolonen
  • 132,868
  • 21
  • 152
  • 208
  • First option won't fit in my case, So, I did not try. I tried the second case but it is not working. – user1423015 Feb 12 '15 at 09:18
  • @user1423015, I just ran from powershell `qwinsta > out.txt` and the output file was encoded in UTF-16 by default. Just open the file with Notepad and it should display the content properly. Your default console font likely doesn't support Chinese. – Mark Tolonen Feb 14 '15 at 07:36
  • My console supports Lucida Console, Consolas and Raster Fonts. I tried with all these but no luck. Which console font did you use? How did you get that? – user1423015 Feb 16 '15 at 08:44
  • I didn't print it on the console. I ran `powershell`, `qwinsta > out.txt`, `notepad out.txt`. The console only supports a limited OEM character set which is typically [code page 437](http://en.wikipedia.org/wiki/Code_page_437) on the US version of Windows unless you change the language used for non-Unicode programs like I mentioned in the answer. – Mark Tolonen Feb 16 '15 at 18:20