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.

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.

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!

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

commented: Superb! Thanks for help! +2

Hie again,

It works! Thanks :D

Yea sure, I will surely post it on SourceForge

Thanks again!

commented: Best of luck. ;-) +25

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

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.