简体   繁体   中英

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?

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...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM