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.
Related
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.
I am having a Whatsapp chat txt file inside of which emojis have been replaced by such text------> "���"
I want to convert that text to specifics emojis. How can I do that and use it inside a java application?
As #Abhishek pointed out, you need to use a different type of encoding. Whatsapp does backup with UTF-8 converting the emoticons into string representations. If you want to see the real emoji, you will have to use Unicode instead. Unicode contains sections which specify emoji as "characters". They're regular characters, you only need a font which can display them. Also see the Unicode Emoji FAQ.
In a text file, characters are basically encoded as numbers in the form of bytes. To display those visually on a computer screen you need a font which contains the visual glyph to render this character. Since the process is always numeric identifier → font → visible glyph, it should be pretty obvious that a "character" can be anything visual, including emoji or any other image.
Maybe all you need is a a font which contains the visual glyph to render these characters. See this for reference.
I have a desktop application in java that converts from literal hindi text to corresponding english translitration. I am using jTextArea in desktop application. Now I want to make a web application for doing the same. My end goal is to have two text areas in html in one of which I can type hindi characters and in other one would show translitration result in english characters at the same time. For Hindi I want to use kruti dev font and Times new roman for english.
Take a look at Cufon: http://cufon.shoqolate.com/generate/
Keep in mind any license issues regarding font usage before making use of a font.
If you want a safe approach, try and find a font you're happy with here: https://www.google.com/fonts
***************************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.
This is similar to my own previous question, but that solution didn't work here.
As mentioned in the previous question, I'm working on a cross platform(Windows/Ubuntu) application that has to transliterate English into one of several official Indian languages. The application has a custom input method, and typing in English and pressing space will transliterate the typed text into the specific local language. Urdu is different from the others in being right to left, like Arabic/Hebrew.
I managed to find an open licensed Urdu font that has both English and Urdu glyphs, but when I type characters in English, nothing shows up.
I don't understand whether it's a font painting issue, or related to the input method. So far, if I disable the custom input method (InputMethod.dispatchEvent() ) for this language, I am able to see the English text (but of course no transliteration takes place).
My findings:
Change font to one of Windows' built in Arabic fonts - same result.
Instead of using ComponentOrientation to align text in the text field, I used setHorizontalAlignment for when the locale is Urdu. Same result.
Decompiled the JDK's default input method provider on Windows (sun.awt.windows.WInputMethod). Here I see the dispatchEvent() makes a native call to the OS for handling IME. I can't do that here.
Found a custom IM for Hebrew - my version of dispatchEvent() is essentially the same.
Stepped through code for JTextField in Eclipse - wasn't able to find anything in the AbstractDocument and subclasses. The AbstractDocument.insertUpdate() method checks for and updates bidirectional text input, but there wasn't anything else significant.
I'm unable to understand what happens after the dispatchEvent() call. The characters are being registered, i.e. the transliteration engine is able to detect the typed characters and process them, but they just don't show up on screen.
Workaround
If I let the text field's orientation be as it is for regular left to right languages, I can see the English text. However, this would not be acceptable to an Urdu speaking user.
Can someone point me in the right direction?
I set the locale to ur_IN.
Sadly, ur_IN is not among the supported locales; I only see en_IN and hi_IN. In the example cited, I used the following code to get the image below:
spinner.setLocale(new Locale("hi", "IN"));