0

I'm working with a Java application's text interface on Windows using PowerShell. As parameters for text commands I need to input words containing non-standard latin characters (Central European). Those parameter words are than compared with words stored in the application's "dictionary". If a parameter matches with some word in dictionary I get expected results.

The problem comes with input encoding. The application stores dicionary words using UTF-8. And I cannot make PowerShell to pass my parameters encoded in UTF-8. They don't match with words in the application because of encoding differences.

I tried to control the input encoding in PowerShell setting $OutputEncoding and [Console]::InputEncoding variables to UTF-8. However, parameters are still wrongly encoded. How to make PowerShell encode keybord input, which is passed to application, using UTF-8?

May the problem actually lay on the Java side?

Denikin
  • 21
  • 1
  • 8

2 Answers2

0

what about defining a reader that encodes to UTF-8?
Here what I do reading from a socket:

    $Enc    = [System.Text.Encoding]::UTF8
    $client = New-Object System.Net.Sockets.TcpClient $IPAddr, $Port 
    $stream = $client.GetStream()
    $reader = New-Object System.IO.StreamReader($stream, $Enc)
gooly
  • 1,241
  • 7
  • 20
  • 38
  • I should choose my local IP address and whichever free port? I'm doing that and I get error when executing second line "host refusing connection". – Denikin Jun 03 '14 at 10:27
  • I don't fully understand your construction of exchanging the text between keyboard, PowerShell, Java and a (more) files. – gooly Jun 03 '14 at 14:52
  • The Java application reads in loop from System.in. I just run the app in PowerShell and type commands defined by the app, which include non-standard latin words. I wish the app could get them as UTF-8. This is actually the app: https://code.google.com/p/airhead-research/wiki/SemanticSpaceExplorer – Denikin Jun 03 '14 at 15:15
0

I found this topic discussed here: Unicode characters in Windows command line - how?

It seems that there is no solution to my problem.

Community
  • 1
  • 1
Denikin
  • 21
  • 1
  • 8