profesorfalken / jPowerShell

Simple Java API to interact with PowerShell console
Apache License 2.0
218 stars 84 forks source link

I got Garbled #12

Closed lisuiheng closed 8 years ago

lisuiheng commented 8 years ago

PowerShellResponse response = powerShell.executeCommand(getAll); //Print results System.out.println("result :" + response.getCommandOutput());

chinese output will Garbled but I can not find how to change coding

profesorfalken commented 8 years ago

Hello,

What is the command you are executing?

Have you tried the same command using PowerShell console?

Regards

lisuiheng commented 8 years ago

I use command is Get-MsolUser -All when name contain chinese is will be Garbled I using PowerShell console output no problem

when I use an other method ,it's no problem too:

Runtime runtime = Runtime.getRuntime(); Process proc = runtime.exec(str); proc.getOutputStream().close(); InputStream inputstream = proc.getInputStream(); InputStreamReader inputstreamreader = new InputStreamReader(inputstream, "GBK");

profesorfalken commented 8 years ago

Hello,

JPowerShell uses UTF-8 so normally you have no need to make encoding conversions in order to show chinese characters. Is your system/jvm using UTF-8 as default encoding? Are you launching directly on console or maybe from your IDE? Have you tried the flag -Dfile.encoding=UTF8?

lisuiheng commented 8 years ago

thanks