0

Considering UTF-8 + Windows CMD nightmare...

After reading this question, are these solutions only partial ? Is there a way to set globally the character set/encoding in a cmd environment? It seems that CHCP command does not change the stdout/stderr encodings.

To check it: write a program that fills a file with latin/korean/ukrainian strings.

On direct output, the file will be ok if you set the encoding properly into your source code (i checked it with Java, easy encoding settings for files). But if you redirect your output into a log file, you will simply have series of ???????????????????? in it ...

The indirection could be useful too, like this:

PROMPT> myprog < inputdata.txt > outputdata.txt

Am i missing something? Is it cmd that badly converts stdout, or Java that adapts System.out, depending of the cmd encoding? I have not found any method to re-define System.out/err encoding.

Grubert
  • 11

1 Answers1

0

Considering UTF-8 + Windows CMD nightmare...

Works for C#.

Should work for Java too, maybe you are doing it wrongly. You should put your problem code on stackoverflow and ask where you are going wrong with the encoding statements.

To check it: write a program that fills a file with latin/korean/ukrainian strings.

I have done something like that in C#

On direct output,

you mean on display

the file will be ok if you set the encoding properly into your source code (i checked it with Java, easy encoding settings for files). But if you redirect your output into a log file, you will simply have series of ???????????????????? in it ...

You have to get the encoding statement correct in your code, then the > will work.

I haven't had to change CHCP in order to just redirect non ascii unicode characters to a file. Or to put it another way.

The indirection could be useful too, like this:

PROMPT> myprog < inputdata.txt > outputdata.txt Am i missing something? Is it cmd that badly converts stdout, or Java that adapts System.out, depending of the cmd encoding? I have not found any method to re-define System.out/err encoding.

It's all an issue with your Java code.

See it work here in C#

https://stackoverflow.com/questions/30904504/font-is-right-why-cant-i-get-this-unicode-character-to-display-in-this-c-sharp

And look at my comment on Htin's answer. But that's for C#

You want it for Java, post your a demonstrative piece of code with your question, to stackoverflow. It's a programming issue that you have.

barlop
  • 25,198