AlexandrM
AlexandrM

Reputation: 137

Java encoding String to cp1251

I have project in 'windows-1251' encoding. And next code print me 'P©' instead 'Щ':

  String var = "Щ";
  Println(var);

I try to convert this String in byte[] format and get different results but there are not correctly. How can I print my primary symbol?

Upvotes: 1

Views: 2449

Answers (1)

Zbynek Vyskovsky - kvr000
Zbynek Vyskovsky - kvr000

Reputation: 18825

You need to specify source encoding. In maven you do this like:

<project.build.sourceEncoding>CP-1251</project.build.sourceEncoding>

But it's generally bad idea to use anything other than UTF-8 nowadays...

Upvotes: 2

Related Questions