?
Solved

Have to print russian language data in JAVA

Posted on 2011-02-16
26
Medium Priority
?
653 Views
Last Modified: 2012-06-21
I get the russian language data from the database adn I am able to view the proper data in my debugger. But when I try to use System.out.println to print the data to check, I am getting everything ???????????. I don't know how to solve this. I am using struts and I don't know what encoding/decoding have they done in the database.

Thanks,
0
Comment
Question by:DHAMIN
  • 8
  • 8
  • 7
  • +2
25 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 34906516
Your console probably doesn't support what you're attempting to do. Are you using Windows?
0
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 664 total points
ID: 34906541
The following will tell you what the runtime thinks your encoding is. It's not interested in the database encoding, although if you have mixed languages, UTF-8 is probably a good choice
System.out.println(System.getProperty("file.encoding"));

Open in new window

0
 

Author Comment

by:DHAMIN
ID: 34906570
Yes. I am using Windows.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:DHAMIN
ID: 34906597
When I tried to check the encoding by using your above code, it returns me Cp1252
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 34906632
Yes, that's all default. It's going to be a lot easier for you to view Russian output in an IDE console. Can you arrange it that way?
0
 

Author Comment

by:DHAMIN
ID: 34906647
Yes. I am trying to print the russian data to my console and I using IntellIJ. Thats when it is printing the ????.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 34906715
You need to use an encoding that supports Russian. In this case, for your debugging purposes, try setting your IDE with

-Dfile.encoding=UTF-8
0
 

Author Comment

by:DHAMIN
ID: 34906733
It is already been set as UTF-8 only.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 34906743
You will of course need Russian font support
0
 

Author Comment

by:DHAMIN
ID: 34906764
Yes. But how will I get that?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 34906894
0
 

Author Comment

by:DHAMIN
ID: 34906915
But I am using windows 7.
0
 
LVL 47

Expert Comment

by:for_yan
ID: 34907113
But did you do necessary setup in Control Panel?
Don't know exactly in Windows7 but in XP you go to Control Panel, Reginal and Language,
Languge - Details - Advanced - Add, and find Russian
Can you see Russian say in Windows Word?
I have IntelliJ and I can see and type Russian within it
0
 
LVL 47

Expert Comment

by:for_yan
ID: 34907154
No, sorry, I was wrong - read the trail more attentively - I can type Russian in IntelliJIdea,
but System.out.println indeed prints ????
0
 
LVL 47

Expert Comment

by:for_yan
ID: 34909676

In Idea go to Settings | File Encodings and change it to UTF-8.
You don't need to add -Dfile.encoding=UTF-8 to runtime JVM - IDEA adds this automatically

Try to change in Settings | File Encodings - it started working for me
when I did it.
0
 

Author Comment

by:DHAMIN
ID: 34910230
Already the encoding is in UTF-8. But it is still printing ?????.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 34910255
You probably don't have Russian font support. Try changing the font
0
 
LVL 47

Expert Comment

by:for_yan
ID: 34910269
Which version of Idea are you using? What Java version?
Fiirst try to create very simple brand new project and set File Encoding to UTF-8 - I also
had some problems but eventually this worked for me, so it probably should work for you.
I have XP rather than Winndows 7, but other than that it is the same.
0
 
LVL 47

Expert Comment

by:for_yan
ID: 34910275
No you have Russian font as you are typing in Russina in the editor window - correct?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 34910931
0
 
LVL 47

Expert Comment

by:for_yan
ID: 34910970
This is rather Idea issue, not general Java -
I just had it System.out.println(russin text here)  - and when I changed this Setting | File Encoding
it started working for me - I'm sure it should work for you
I have version 9.0.1 of Idea, but I'm pretty sure it should be the same
on previouis versions.

can you see Russian in say Word for Windows on your computer?
But I think once you can see it in the editor window of Idea, it should also work in System.out.print
with this setting
0
 
LVL 47

Expert Comment

by:for_yan
ID: 34911733
I attach a very simple project created by Idea 9 - if you have 9 or 10 - it should work
for you. Just rename the RussianPrintout2.txt to RussianPrintout2.iml
and the folder "idea" to  ".idea" (dot should be the first character),
as EE do not allow to upload .iml files and foleders starting with dot

I guess if it works for me and prints in Russian, why shouldn't it work for you

RussianPrintout2.zip
0
 
LVL 92

Accepted Solution

by:
objects earned 672 total points
ID: 34911897
you should just need to change the encoding of your project to UTF8, no need to worry about the font

0
 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 664 total points
ID: 34911941
Yes, it is in File Encoding in settings of the project that needs to be changed to UTF-8; it should work.
0
 
LVL 60

Expert Comment

by:Kevin Cross
ID: 37514370
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month15 days, 18 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question