This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 21 Developer Study Guide: Exam 1Z0-830 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

NetBeans UTF8 Encoding Problem?

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi iam making an application that uses arabic words encoded in UTF8 like the following
String str1=new String( "مرحبا".getBytes() , "UTF8");
but when i try to run the code in NetBeans,The Data Is Displayed As ???
Although My Windows Language Is Arabic?
also in the project properities>sources>Encoding>UTF-8 ?
also in project properities>build>compiling>additional compiler options>-encoding UTF-8 ?
also i tried to edit the netbeans.conf file by adding the encoding
netbeans_default_options="................ -J-Dfile.encoding=UTF-8" ?
every thing is completely right but the program keeps displaying the words as ???
but when i try to run the same code in IDE Like JCreator The Data Is Displayed Correctly?
so any ideas how to fix this problem ?
iam using NetBeans 6.5M1
Windows XP
JDK 6u4
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
String.getBytes returns a byte array in the platform default encoding, which most likely is not UTF-8. So if you then try to construct a String from it by telling the JVM that it is UTF-8, you've got a problem.

Have you tried using just: String str1 = "مرحبا";
[ September 12, 2008: Message edited by: Ulf Dittmer ]
 
mahmoud saleh
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes you are right
that's did it
 
Think of how stupid the average person is. And how half of them are stupider than that. But who reads this tiny ad?
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic