Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to print russian characters

I have a russian string which i have encoded to UTF-8

String str = "\u041E\u041A";
System.out.println("String str : " + str);

When i print the string in eclipse console i get ?? Can anyone suggest how to print the russian strings to console or what i am doing wrong here?

I have tried converting it to bytes using byte myArr[] = str.getBytes("UTF-8") and then new String(myArr, "UTF-8") still same problem :-(

like image 671
Rohit Avatar asked Jun 18 '13 12:06

Rohit


3 Answers

In eclipse Go to Run > Run Configuration > Common > Change the console encoding to UTF-8. You will be able to see the Russian Characters in console

like image 90
Ankit Pandoh Avatar answered Oct 21 '22 02:10

Ankit Pandoh


Try this:

String myString = "some cyrillic text";
byte bytes[] = myString.getBytes("ISO-8859-1"); 
String value = new String(bytes, "UTF-8"); 

Or this:

String myString = "some cyrillic text";
byte bytes[] = myString.getBytes("UTF-8"); 
String value = new String(bytes, "UTF-8"); 

The main problem with russian its to set UTF-8 encoding correctly.

like image 6
Lugaru Avatar answered Oct 21 '22 00:10

Lugaru


My Eclipse prints it correctly

String str : ОК

try to change Run Configurations encoding to UTF-8 or CP1251

like image 1
Evgeniy Dorofeev Avatar answered Oct 21 '22 01:10

Evgeniy Dorofeev