profesorfalken / jPowerShell

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

Trouble with special characters #16

Closed RunarAnd closed 7 years ago

RunarAnd commented 7 years ago

When one is trying to pass special characters it fails To recreate:

`public class Main { public static void main(String[] args){ //Execute a command in PowerShell session PowerShellResponse response = PowerShell.executeSingleCommand("$var1 = \"æøøå\"; $var1 | Out-File text.txt");

    //Print results
    System.out.println(response.getCommandOutput());

}

}`

The content of the text.txt file is then ├ª├©├©├Ñ and it should be "æøøå"

profesorfalken commented 7 years ago

Hello,

It is weird because normally it should use the default encoding of your system JVM.

I have built a snapshot version that contains a modification in order to force UTF-8.

Could you check if it works? https://oss.sonatype.org/content/repositories/snapshots/com/profesorfalken/jPowerShell/1.7-SNAPSHOT/jPowerShell-1.7-20170423.164412-1.jar

Best regards

Harinus commented 7 years ago

Hi,

the issue is that the Powershell instance is not using the JVM default Encoding. See my Pull Request.

Best Regards, Harinus