This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Micro Frontends in Action and have Michael Geers on-line!
See this thread for details.
Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

System.out Arabic Text

 
Ranch Hand
Posts: 226
1
jQuery Postgres Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am trying to work with some arabic text for a web app, however I cannot get my program to output arabic text as per example below:



which generates the following output

Some SOME_ENGLISH_TEXT:some english text
Some SOME_ARABIC_TEXT:??? ??? ???



Basically, when I try to write Arabic text to System.out I get question marks as output.
It is strange because when I enter text through a web form, and then through a middle layer write it to a MySql database, or write it to a webpage like


It all comes out OK.

I am on Windows 7, my IDE is netbeans 6.8.

Any assistance on how to approach arabic text in a java web context would be appreciated.

Thanks

Marten
 
Saloon Keeper
Posts: 12275
259
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is not your program, it's the console. The console uses a font that doesn't contain glyphs for Arabian characters.

What you could do is make a custom output window in Swing (with a simple JTextArea component) and set the font to something like MS Gothic, and redirect System.out to your custom output window using a PipedWriter/PipedOutputStream. Alternatively, you can output to a textfile and open it in an editor using a font like MS Gothic.

[edit]

I rarely work with IDEs, maybe you can set the font of your IDEs output window? That should be a fairly simple trick.
 
marten koomen
Ranch Hand
Posts: 226
1
jQuery Postgres Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Stephan

I also get "???" when I write the string to a file and then open in NotePad, WordPad or MS Word, even after changing the font MS PGothic and others.

I use the code below to write the file.

Is there anyway I can improve this code so that it writes UTF-8?

Cheers
 
Stephan van Hulst
Saloon Keeper
Posts: 12275
259
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
marten koomen
Ranch Hand
Posts: 226
1
jQuery Postgres Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow, awesome.

This is great... I will need to study up on my streams. I tried the Printstream on the file output as well (below) and it worked.



Thanks again.

Cheers
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic