Need help on Unicode (GURMUKHI) in java

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Nov 2007
Posts: 121
Reputation: puneetkay is on a distinguished road 
Solved Threads: 23
puneetkay's Avatar
puneetkay puneetkay is offline Offline
Junior Poster

Need help on Unicode (GURMUKHI) in java

 
0
  #1
Dec 11th, 2008
Hello everyone,

Im trying to write Punjabi (Gurmukhi) by Unicode. I have the Unicode code point of all character and Code Block is Gurmukhi.

  1. System.out.prinln("\u0A73")
u0A73 = GURMUKHI URA = ੳ

but its showing "?".

then i tried with PrintStream

  1. String unicodeMessage = "\u0A73";
  2. try {
  3. PrintStream output = new PrintStream(System.out, true, "UTF-8");
  4. output.print(unicodeMessage);
  5. } catch (UnsupportedEncodingException e) {
  6. e.printStackTrace();
  7. }
now its showing "ੳ".

Tried with UTF-16 and UTF-32 too.

so, i decided to post here for help. can anyone help me to sort out this problem ?

Thanks in advance.
Last edited by puneetkay; Dec 11th, 2008 at 9:56 am.
Puneet Kalra
www.PuneetK.com
Sun Certified Java Programmer


Admin of Pikk - Object Relational Mapping Framework
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,648
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 474
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: Need help on Unicode (GURMUKHI) in java

 
0
  #2
Dec 12th, 2008
There is as such no problem with your code; IMO the fault lies with the incompetence of the shell to render fonts correctly. I assume you are on a windows box? Anyways, this is just a rendering issue. Maybe a little more background on what you are trying to achieve here would be required to offer some advice.

Anyways, to mess around with code points and to get a feel of how the characters looks, try this sample snippet which creates an HTML document 'test.html'.
  1. // Error handling and best practices omitted for brevity
  2.  
  3. public class HtmlTester {
  4.  
  5. private final static String HTML =
  6. "<html><head><META HTTP-EQUIV=\"Content-Type\" " +
  7. "CONTENT=\"text/html; charset=UTF-8\"></head><body><div>{0}" +
  8. "</div></body></html>";
  9.  
  10. public static void main(final String[] args) throws Exception {
  11. testIt();
  12. }
  13.  
  14. public static void testIt() throws Exception {
  15. String toWrite = MessageFormat.
  16. format(HTML, String.valueOf("\u0A72 \u0A73 \u0A74"));
  17. writeData(toWrite, new File("test.html"));
  18. }
  19.  
  20. public static void writeData(String s, File f) {
  21. try {
  22. BufferedWriter out = new BufferedWriter(new OutputStreamWriter(
  23. new FileOutputStream(f), "utf-8"));
  24. out.write(s);
  25. out.flush();
  26. out.close();
  27. } catch(Exception e) {
  28. e.printStackTrace();
  29. }
  30. }
  31.  
  32. }
The gurmukhi characters are displayed correctly since I guess browsers have their own font rendering engine.
I don't accept change; I don't deserve to live.

Jo Tujhe Jagaaye, Nindein Teri Udaaye Khwaab Hai Sachcha Wahi.
Nindon Mein Jo Aaye Jise To Bhul Jaaye Khawab Woh Sachcha Nahi.
Khwaab Ko Raag De, Nind Ko Aag De
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 121
Reputation: puneetkay is on a distinguished road 
Solved Threads: 23
puneetkay's Avatar
puneetkay puneetkay is offline Offline
Junior Poster

Re: Need help on Unicode (GURMUKHI) in java

 
0
  #3
Dec 12th, 2008
Hello,

Thanks for reply,
Actually, im creating a virtual Punjabi keyboard. On swing components, I used setFont() method and working perfectly. But i also need to display it on Console.

Im using Windows Vista and Eclipse IDE.

Im still on it, hope to the solution soon.

Thanks again!
Puneet Kalra
www.PuneetK.com
Sun Certified Java Programmer


Admin of Pikk - Object Relational Mapping Framework
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,648
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 474
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: Need help on Unicode (GURMUKHI) in java

 
1
  #4
Dec 12th, 2008
If you plan on viewing the output on Eclipses's console, it shouldn't be that big a problem. Try following the advice in this post.

But if you are stuck with windows console, then there isn't a reliable / sure shot way of getting it to work. Many have suggested setting the code page to 65001 though I am not very sure whether it works in all cases.

Let me know if the above suggested fixes work in your case. Best of luck for your project; hoping to see it on sourceforge. ;-)
I don't accept change; I don't deserve to live.

Jo Tujhe Jagaaye, Nindein Teri Udaaye Khwaab Hai Sachcha Wahi.
Nindon Mein Jo Aaye Jise To Bhul Jaaye Khawab Woh Sachcha Nahi.
Khwaab Ko Raag De, Nind Ko Aag De
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 121
Reputation: puneetkay is on a distinguished road 
Solved Threads: 23
puneetkay's Avatar
puneetkay puneetkay is offline Offline
Junior Poster

Re: Need help on Unicode (GURMUKHI) in java

 
1
  #5
Dec 13th, 2008
Hie again,

It works! Thanks

Yea sure, I will surely post it on SourceForge

Thanks again!
Puneet Kalra
www.PuneetK.com
Sun Certified Java Programmer


Admin of Pikk - Object Relational Mapping Framework
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,648
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 474
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: Need help on Unicode (GURMUKHI) in java

 
0
  #6
Dec 13th, 2008
So, were you trying it on Eclipse or windows console? BTW, bump this thread when your project is completed. :-)
I don't accept change; I don't deserve to live.

Jo Tujhe Jagaaye, Nindein Teri Udaaye Khwaab Hai Sachcha Wahi.
Nindon Mein Jo Aaye Jise To Bhul Jaaye Khawab Woh Sachcha Nahi.
Khwaab Ko Raag De, Nind Ko Aag De
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 121
Reputation: puneetkay is on a distinguished road 
Solved Threads: 23
puneetkay's Avatar
puneetkay puneetkay is offline Offline
Junior Poster

Re: Need help on Unicode (GURMUKHI) in java

 
0
  #7
Dec 13th, 2008
Originally Posted by ~s.o.s~ View Post
So, were you trying it on Eclipse or windows console? BTW, bump this thread when your project is completed. :-)
On Eclipse

bump this thread ?? didnt get you ..
Puneet Kalra
www.PuneetK.com
Sun Certified Java Programmer


Admin of Pikk - Object Relational Mapping Framework
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,648
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 474
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: Need help on Unicode (GURMUKHI) in java

 
0
  #8
Dec 13th, 2008
I meant post a reply here once it is completed and up on sourceforge, so that I can get a notification; it might interest the kids new to Java.
I don't accept change; I don't deserve to live.

Jo Tujhe Jagaaye, Nindein Teri Udaaye Khwaab Hai Sachcha Wahi.
Nindon Mein Jo Aaye Jise To Bhul Jaaye Khawab Woh Sachcha Nahi.
Khwaab Ko Raag De, Nind Ko Aag De
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 121
Reputation: puneetkay is on a distinguished road 
Solved Threads: 23
puneetkay's Avatar
puneetkay puneetkay is offline Offline
Junior Poster

Re: Need help on Unicode (GURMUKHI) in java

 
0
  #9
Dec 13th, 2008
Originally Posted by ~s.o.s~ View Post
I meant post a reply here once it is completed and up on sourceforge, so that I can get a notification; it might interest the kids new to Java.
Oh yea sure! I will surely notify you and post here too.
Puneet Kalra
www.PuneetK.com
Sun Certified Java Programmer


Admin of Pikk - Object Relational Mapping Framework
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the Java Forum
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC