Link to home
Start Free TrialLog in
Avatar of DHAMIN
DHAMIN

asked on

Have to print russian language data in JAVA

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,
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Your console probably doesn't support what you're attempting to do. Are you using Windows?
SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DHAMIN
DHAMIN

ASKER

Yes. I am using Windows.
Avatar of DHAMIN

ASKER

When I tried to check the encoding by using your above code, it returns me Cp1252
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?
Avatar of DHAMIN

ASKER

Yes. I am trying to print the russian data to my console and I using IntellIJ. Thats when it is printing the ????.
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
Avatar of DHAMIN

ASKER

It is already been set as UTF-8 only.
You will of course need Russian font support
Avatar of DHAMIN

ASKER

Yes. But how will I get that?
Avatar of DHAMIN

ASKER

But I am using windows 7.
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
No, sorry, I was wrong - read the trail more attentively - I can type Russian in IntelliJIdea,
but System.out.println indeed prints ????

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.
Avatar of DHAMIN

ASKER

Already the encoding is in UTF-8. But it is still printing ?????.
You probably don't have Russian font support. Try changing the font
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.
No you have Russian font as you are typing in Russina in the editor window - correct?
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
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
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.