java swing jtextfiled unicode sinhala - java

***************************UPDATED***********************************************************************
i have found a similar question :
here : same question by another user
this one is with little details , but i still cant get it to work !
any help would be glad fully accepted !
I want to type Sinhalese words in (J2SE)swing textfileds , but they don't appear correctly in Java , same text in notepad shows correct word. how can i fix this ?
notepad picture:
http://imageupper.com/i/?S0200010080011O13734602521426968
java picture :
http://imageupper.com/i/?A0300010070011I13734604591427932

The same letters are in both images, so it's not problem of encoding.
The problem is that you have to set a proper font to the textfield. You can create the font if you don't have it, check this setting custom font
#AndrewThompson answer :)

Edit: That other user with the same question that you have mentioned is me. :)
As I found out, the char data type is not enough to render letters like "ශ්‍ර" because it needs 3 8bit characters. And the Java language isn't going to change the size of char data type just because we Sri Lankans want to render our characters. I had the similar question previously and I am the user you mentioned in your question.
"ශ්‍ ර" is shown with 2 8bit characters for each character and that's all we got till now. You might want to checout SWT because it shows characters pretty damn well in my experience.

Related

How do I print non English text from its unicode in Android

I need to display non English text in it's own language. Ex: Japanese name in Japanese
This is the code,
String.format(Locale.JAPANESE,"%s %s","%E9%A6%96%E7%9B%B8","%E9%A6%96%E7%9B%B8");
The out put for this is : %E9%A6%96%E7%9B%B8
The converting not work. But if I print Japanese text(not the unicode), it is displaying on Android screen so not a font issue.
I read similar questions and answers here and non of them work for me.
Please help.
For unicode, you can try, say you have a TextView:
textView.setText(Html.fromHtml(your_unicode_here));
If you need to translate it, I suggest you use a translation API or a hard-coded mapped solution w/ Japanese, English strings etc.

Create text modification system like the answerfield on stackoverflow

In my android app, I want to create a text field with a lot of modification options (strong text, emphasized text, enter code here, enter link description here) like on stackoverflow.
I thought about this option:
In the answerfield of stackoverflow, strong texts are wrapped in "** **" and emphasized texts in "* *".
So I could conclude that every modification option have different special characters.
In the answer editor the special characters (**, *) are visible, so the special characters are inserted in the stackoverflow database.
So the only possibility is, that the text is interpreted after receiving it from database.
Is my guess right?
Can one of you give me a little bit android code of such a text modifier, so that I know how to start?
Just iterate About the Content in the textField and if you find a construct like ** then replace the following with a String in the whished font.

Arabic in java error

I'm working currently on java project that uses Arabic Language, I found difficulty in writing in Arabic as shown in the image:
I wrote Arabic without any edit.
I added a reverse() method, it worked good but the letters aren't attached to each other, they're separate.
StringBuilder input = new StringBuilder();
input.append(jTextField2.getText());
input = input.reverse();
jTextField1.setText(input.toString());
I use site the flip the text, it didn't work as well.
I use the same site, but with jLabel it worked.
other method I use, but didn't work:
Try Orientation jTextField1.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
Change the IDE encoding to URT-8 (I'm using Netbeans-JDK8).
Can anyone help me how to write & print Arabic in java correctly?
Please refer to this question -
Forcing RTL order in a JTextArea
Here is a sugestion to start the string with the character \u202e to force the text to be RTL.
Also i think it is not good approach to reverse the string, as it is not good user experience when the user do "copy paste", as he will copy reversed string...
A string entirely composed of characters from the Arabic block should render with correct RTL presentation without any directionality control characters. If it does not, it is likely that you have a problem with your operating system configuration, not with your Java code. Reversing the string is a terrible idea. Trying for visual-order rendering is going to get all messed up.

Display 2D text on screen simply

I have been looking through forum posts, blogs, videos, and various other websites for the past hour trying to figure out how to display text on the screen. From what I have seen this is not very simple to do. (Maybe it is once you know how to actually do it)
I decided (with a bit of regret) to post this question here. I am sorry if this question has already been asked a million times, but I am just not understanding how to get this to work. All of the code I have tried so far has not worked.
I would just like to know how I can display text on the screen. I do not want to use my own font or anything fancy. I would just like to know the simplest way to display text on the screen.
The simplest way would be to use Slick. Here's a link to the page specifically about loading and using fonts within your LWJGL program:
Slick-Util (Part 3) - TrueType Fonts for LWJGL
I am learning java currently and I love the newbostin, he makes simple fast tutorials but to display text I'm pretty sure u need to
1: have eclipse
2: make the base of it (the main string, idk how actually)
3. The actual code to do it is println("text here")
I'm not completely sure so you should check out the newBoston he is awesome at explaining.

Unicode character (ரு) in Swing text box

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.
For this type of characters font and uni coding must be supported by the system.

Categories