• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 680
  • Last Modified:

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,
0
DHAMIN
Asked:
DHAMIN
  • 8
  • 8
  • 7
  • +2
3 Solutions
 
CEHJCommented:
Your console probably doesn't support what you're attempting to do. Are you using Windows?
0
 
CEHJCommented:
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
 
DHAMINAuthor Commented:
Yes. I am using Windows.
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
DHAMINAuthor Commented:
When I tried to check the encoding by using your above code, it returns me Cp1252
0
 
CEHJCommented:
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
 
DHAMINAuthor Commented:
Yes. I am trying to print the russian data to my console and I using IntellIJ. Thats when it is printing the ????.
0
 
CEHJCommented:
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
 
DHAMINAuthor Commented:
It is already been set as UTF-8 only.
0
 
CEHJCommented:
You will of course need Russian font support
0
 
DHAMINAuthor Commented:
Yes. But how will I get that?
0
 
CEHJCommented:
0
 
DHAMINAuthor Commented:
But I am using windows 7.
0
 
for_yanCommented:
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
 
for_yanCommented:
No, sorry, I was wrong - read the trail more attentively - I can type Russian in IntelliJIdea,
but System.out.println indeed prints ????
0
 
for_yanCommented:

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
 
DHAMINAuthor Commented:
Already the encoding is in UTF-8. But it is still printing ?????.
0
 
CEHJCommented:
You probably don't have Russian font support. Try changing the font
0
 
for_yanCommented:
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
 
for_yanCommented:
No you have Russian font as you are typing in Russina in the editor window - correct?
0
 
CEHJCommented:
0
 
for_yanCommented:
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
 
for_yanCommented:
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
 
objectsCommented:
you should just need to change the encoding of your project to UTF8, no need to worry about the font

0
 
for_yanCommented:
Yes, it is in File Encoding in settings of the project that needs to be changed to UTF-8; it should work.
0
 
Kevin CrossChief Technology OfficerCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 8
  • 8
  • 7
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now