0

Hello everyone,

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

System.out.prinln("\u0A73")

u0A73 = GURMUKHI URA = ੳ

but its showing "?".

then i tried with PrintStream

String unicodeMessage = "\u0A73";
		   try {
			   PrintStream output = new PrintStream(System.out, true, "UTF-8");
					output.print(unicodeMessage);
				} catch (UnsupportedEncodingException e) {
					e.printStackTrace();
				}

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.

2
Contributors
8
Replies
10
Views
8 Years
Discussion Span
Last Post by puneetkay
Featured Replies
  • 1
    ~s.o.s~ 2,560   8 Years Ago

    If you plan on viewing the output on Eclipses's console, it shouldn't be that big a problem. Try following the advice in [URL="http://paranoid-engineering.blogspot.com/2008/05/getting-unicode-output-in-eclipse.html"]this [/URL]post. But if you are stuck with windows console, then there isn't a reliable / sure shot way of getting it to work. [URL="http://stackoverflow.com/questions/54952/java-utf-8-and-windows-console"]Many have suggested[/URL] setting … Read More

  • Hie again, It works! Thanks :D Yea sure, I will surely post it on SourceForge Thanks again! Read More

0

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'.

// Error handling and best practices omitted for brevity

public class HtmlTester {

  private final static String HTML = 
  "<html><head><META HTTP-EQUIV=\"Content-Type\" " +
      "CONTENT=\"text/html; charset=UTF-8\"></head><body><div>{0}" +
      "</div></body></html>";

  public static void main(final String[] args) throws Exception {
    testIt();
  }

  public static void testIt() throws Exception {
    String toWrite = MessageFormat.
      format(HTML, String.valueOf("\u0A72 \u0A73 \u0A74"));
    writeData(toWrite, new File("test.html"));
  }

  public static void writeData(String s, File f) {
    try {
      BufferedWriter out = new BufferedWriter(new OutputStreamWriter(
          new FileOutputStream(f), "utf-8"));
      out.write(s);
      out.flush();
      out.close();
    } catch(Exception e) {
      e.printStackTrace();
    }
  }

}

The gurmukhi characters are displayed correctly since I guess browsers have their own font rendering engine.

0

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!

1

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. ;-)

Comments
Superb! Thanks for help!
1

Hie again,

It works! Thanks :D

Yea sure, I will surely post it on SourceForge

Thanks again!

Comments
Best of luck. ;-)
0

So, were you trying it on Eclipse or windows console? BTW, bump this thread when your project is completed. :-)

0

So, were you trying it on Eclipse or windows console? BTW, bump this thread when your project is completed. :-)

On Eclipse :D

bump this thread ?? didnt get you ..

0

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.

0

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.