prime
prime

Reputation: 15574

Can't see Sinhala Unicode characters in NetBeans

I tried to print Sinhala characters in NetBeans 7.1 Java application.(In windows 7) Other languages like Chinese and Urdu .. etc will show the correct character. But Sinhala characters are not displaying correctly. It will display as little boxes both in the code and the output. though here in SO it show as "සිංහල" . How can I fix it ?

I can do this without a problem in eclipse environment.

    String a = "世界你好";
    System.out.println(a);
    System.out.println("कई");

    // sinhala
    char c = '\u0D85';
    System.out.println(c);
    System.out.println("\u0D85");
    System.out.println("සිංහල");

    System.out.println(java.nio.charset.Charset.defaultCharset().name());

I tried changing the Sources -> Encoding type to UTF-8. and now my netbeans.conf file I changed netbeans_default_options and added -J-Dfile.encoding=UTF-8 like below

netbeans_default_options="-J-Dfile.encoding=UTF-8 -J-Dorg.netbeans.modules.tomcat.autoregister.token=1378930362898 -J-Dorg.netbeans.modules.tomcat.autoregister.catalinaHome=\"C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.20\" -J-Dorg.glassfish.v3ee6.installRoot=\"C:\Program Files\sges-v3\" -J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.zip.disableMemoryMapping=true"

How can I fix this. ?

Upvotes: 3

Views: 2639

Answers (2)

Chandana Gihan Perera
Chandana Gihan Perera

Reputation: 51

For each textbox or edittext set font into iscolapota.

Upvotes: 0

leo4jc
leo4jc

Reputation: 205

The default monospaced font in Netbeans is not sufficient for unicode characters. Try using a unicode font that supports Sinhala. Windows 8 comes with Iskoola Pota and Nirmala UI which can display Sinhala nicely. I don't know if you can find these two fonts on Windows 7, but you can download GNU FreeFont (only FreeSerif has Sinhala) as an alternative to Iskoola Pota or Nirmala UI.

To see Sinhala characters in the editor display, select Netbeans menu: Tools => Options ==> Fonts & Colors => Syntax Tab => Category Default => Font and set it to either Iskoola Pota or Nirmala UI or FreeSerif.

Likewise, to see Sinhala characters in the output display, select Netbeans menu: Tools ==> Options ==> Miscellaneous ==> Output tab ==> Font and set it to either Iskoola Pota or Nirmala UI or FreeSerif. You can right click on the output display and choose Settings... to go there directly.

This is your code and output in Netbeans 8.0.2 on Windows 8 with FreeSerif font.

enter image description here

More reading on Sinhala fonts: Unicode Font and List of typefaces included with Microsoft Windows

Upvotes: 7

Related Questions