1

In Browser the Unicode character (ரு) is showing properly. If I copy paste it in swing textfield it appears wrong.

PS: it is the combination of two character. Please help on this.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Deepak Sah
  • 11
  • 1
  • 4
    Does the font used in the Swing textfield actually have that caracter? – ppeterka Apr 02 '13 at 11:46
  • and with Locale if we talking about WinXp – mKorbel Apr 02 '13 at 11:50
  • I am working on Macintosh. and I am copying an pasting the character from browser to text box. – Deepak Sah Apr 02 '13 at 11:55
  • Try adding -Dfile.encoding=utf8 to your VM args to make sure that it's defaulting to UTF8 and not MacRoman. – Kylar Apr 02 '13 at 12:00
  • System.getProperty("file.encoding") is giving me "UTF-8" – Deepak Sah Apr 02 '13 at 12:07
  • @Deepak Sah I'm not able to copy from [this site](http://en.wiktionary.org/wiki/Index:Tamil/%E0%AE%B0%E0%AF%81) to the Swing JTextComponents, have to search for proper Font(s) that supporting those Chars – mKorbel Apr 02 '13 at 12:08
  • Thats my problem. If I copy paste the character in Terminal of Mac, it appears OK. It also works find with mail and textEdit applications. but not in my Swing Textbox. – Deepak Sah Apr 02 '13 at 12:12
  • @DeepakSah Try to change the font of the text field to the same font that mail or textEdit are using – mavroprovato Apr 02 '13 at 12:21
  • I am not using any specific font for mail or textedit. Even Terminal is showing it correctly. In general, one character has one unicode. But, sometime, one character is made up of two unicodes. You can see lot of examples here: [link]tdil-dc.in/utrrs/language/ta/gpos – Deepak Sah Apr 02 '13 at 12:22
  • @DeepakSah, I'm not saying that you are using a custom font for those applications. But those applications are using *some* System font that supports this character, and Swing uses another that does not support it. Try to find out which is that font that supports that character and use it in your text field. – mavroprovato Apr 02 '13 at 12:48
  • As everyone else is saying, it is definitely a problem with the font. You have to make sure that your textfield is using a font which can display that character. I have copied and pasted this character into my own program using the font "Arial Unicode MS" and it works fine. The default fonts used by Java on Windows do not include this character, but certain fonts, such as "Arial Unicode MS" do contain it. (On Macintosh, the font you need will probably be a different one.) `UIManager.getLookAndFeelDefaults().put("defaultFont", new Font(...));` – Enwired Apr 02 '13 at 21:10
  • See http://stackoverflow.com/questions/7434845/setting-the-default-font-of-swing-program-in-java – Enwired Apr 02 '13 at 21:11
  • [You probably mean it appears like `ர​ு` instead of `ரு`](http://i.imgur.com/JChpiPU.png)? – Esailija Apr 03 '13 at 10:46
  • Yes and by applying font "Arial Unicode MS" on textfield I got the good appearance in Windows but in Mac it is still missing as corresponding font to arial Unicode ms is not found. Thanks Enwired. – Deepak Sah Apr 03 '13 at 14:05

1 Answers1

0

For this type of characters font and uni coding must be supported by the system.

Saurabh Agarwal
  • 323
  • 2
  • 6
  • 16
  • If copy paste the same character in Terminal or TextEdit or mail, its working fine. – Deepak Sah Apr 02 '13 at 12:00
  • Ok than it's good. Means you need only to handle it at java level. In swings set the font style which supports it and installed in the system. – Saurabh Agarwal Apr 02 '13 at 12:01
  • its not the font style rather rendering the combination of Unicode. In general, one character has one unicode. But, sometime, one character is made up of two unicodes. You can see lot of examples here: [link]http://www.tdil-dc.in/utrrs/language/ta/gpos – Deepak Sah Apr 02 '13 at 12:14