Arabic text to display
I have text file with arabic words. I need to read file (this part is done) and to display some words from file. But it does not shows arabic symbols. How can I make it?
I found solution:
private final String readUnicodeFileUTF8(String filename) {
StringBuffer sb = new StringBuffer(256);
try {
int[] surrogatePair = new int[2];
InputStream is = this.getClass().getResourceAsStream(filename);
int val = 0;
int unicharCount = 0;
while ((val = readNextCharFromStreamUTF8(is))!=-1) {
unicharCount++;
if (val <= 0xFFFF) {
// if first value is the Byte Order Mark (BOM), do not add
if (! (unicharCount == 1 && val == 0xFEFF)) {
sb.append((char)val);
} else {
supplementCodePointToSurrogatePair(val, surrogatePair);
sb.append((char)surrogatePair[0]);
sb.append((char)surrogatePair[1]);
is.close();
} catch (Exception e) {};
return new String(sb);
private final static int readNextCharFromStreamUTF8(InputStream is) {
int c = -1;
if (is==null) return c;
boolean complete = false;
try {
int byteVal;
int expecting=0;
int composedVal=0;
while (!complete && (byteVal = is.read()) != -1) {
if (expecting > 0 && (byteVal & 0xC0) == 0x80) { /* 10xxxxxx */
expecting--;
composedVal = composedVal | ((byteVal & 0x3F) << (expecting*6));
if (expecting == 0) {
c = composedVal;
complete = true;
//System.out.println("appending: U+" + Integer.toHexString(composedVal) );
} else {
composedVal = 0;
expecting = 0;
if ((byteVal & 0x80) == 0) { /* 0xxxxxxx */
// one byte character, no extending byte expected
c = byteVal;
complete = true;
//System.out.println("appending: U+" + Integer.toHexString(byteVal) );
} else if ((byteVal & 0xE0) == 0xC0) { /* 110xxxxx */
expecting = 1; // expecting 1 extending byte
composedVal = ((byteVal & 0x1F) << 6);
} else if ((byteVal & 0xF0) == 0xE0) { /* 1110xxxx */
expecting = 2; // expecting 2 extending bytes
composedVal = ((byteVal & 0x0F) << 12);
} else if ((byteVal & 0xF8) == 0xF0) { /* 11110xxx */
expecting = 3; // expecting 3 extending bytes
composedVal = ((byteVal & 0x07) << 18);
} else {
// non conformant utf-8, ignore or catch error
} catch (Exception e) {
System.out.println(e.toString());
return c;
private final static void supplementCodePointToSurrogatePair(int codePoint, int[] surrogatePair) {
int high4 = ((codePoint >> 16) & 0x1F) - 1;
int mid6 = ((codePoint >> 10) & 0x3F);
int low10 = codePoint & 0x3FF;
surrogatePair[0] = (0xD800 | (high4 << 6) | (mid6));
surrogatePair[1] = (0xDC00 | (low10));
}[http://www.j2meforums.com/forum/index.php?topic=9553.0]
Similar Messages
-
Arabic text not displaying correctly in Win Server 2008 R2
Hi,
We have an .mdb database stored on our Windows Server 2008 R2 server but when we view the contents some of the text has strange characters.
When we view the same db in Windows Server 2003 we do not have these characters. I'm not sure what exactly we need to do to correct this issue..
Any suggestions welcome..Hi,
Thanks for your post.
When you open a Web page or a text file that contains a string of Arabic characters, the string is not displayed correctly. This issue occurs when the following conditions are true:
The Left-to-Right Override (LRO) Unicode control character is used in the string of Arabic characters.
You specify a font that is not Simplified Arabic Fixed.
Please apply the hotfix below:
Incorrectly displayed Arabic characters in Windows 7 or in Windows Server 2008 R2
https://support2.microsoft.com/kb/976525?wa=wsignin1.0
And check the result.
Regards.
Vivian Wang -
Problem displaying arabic text in xml document
Hi ..
I have an xml type coloum where i store an xml document that contains some arabic texts with UTF-8 encoding, m using an xsl file to transform the xml and display it in an html page.
At the database level when i select the xml col to dispaly the document, arabic texts are displayed correctly (DB is set to 1256), however when trying to display the text on html it gives me junk values. XSL sheet's encoding is set to windows-1256. M using Jdeveloper 1012 and BC4J frame work in my application.
How do i solve this problem.?
P.S.it wud b great if u support ur answer with examples .
RegardsYou have to do it yourself - I don't have a ready solution. Just look into documentation how StyleSheets are used and see what properties work best for you:
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/text/TextField.html
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/text/StyleSheet.html
Also, with embedded fonts you need to play with TextFormat settings and AntiAliasType
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/text/AntiAliasType.html
In addition, on my machine even if I don't emebed fonts - Arabic works in Arial, TImes and others. -
Wrong arabic text display on Mac - not joint - (good on windows)
Hi,
exported for air 2.6 from within flash CS5.5, executed with latest AIR framework (2.7...).
As you can see in the screenshot, the same air project, run on windows or on mac, shows arabic text differently.
TextField is set to "_sans" device font text (otherwise it doesn't join even on windows).
As you can see from the screenshot, underlying is the project running on windows, and the arabic text looks good. On top, is the same air project on Mac, and the arabic text is displayed wrong (not joint, look closely you will notice differences).
Text is loaded externally from an utf8 xml file.
Any suggestion? I wouldnt like to convert hundreds of buttons and tabs into graphics... And we need multilanguage support.
thank you
Filippo
PS
Notice below (stacked on top) is mac version.Thank you for the report. Would you mind opening a new bug for this issue on our public bug database? Please attach any sample code/project you have that would help us quickly reproduce the text issue.
Thanks,
Chris -
Hi All,
I am downloading my data using GUI_DOWNLOAD FM into Excel ,
Here the issue is in excel the Arabic text is displayed as # ,
I have gone through the scn and worked on some suggestions given like to add code page
tab delimiter etc... but could get the desired output..
can anyone suggest me the way to get the Arabic text correct in Excel.
Thanks,
PavanHi Pavan,
Could you please describe shortly about how ,where is the data being retrieved to the program?
whether you are performing any conversions?
what kind of encoding used ?
it would help me to understand and give you the useful inputs to achieve the desired output
Regards,
Prakash -
Hello,
I'm having problems getting Arabic text to display correctly in the MHP set-top boxes. I have uploaded a .pfr file converted from Arial and the characters are displayed, but they are not connected and the text direction is left-to-right instead of right-to-left.
Any idea what could be wrong? This has been tried in ADB and Philips Silver Box.
Thanks in advanceThe most likely cause here is missing locales. Only the English locale is required on an MHP receiver - all of the other locales from Java are optional, for space reasons. Since the STB just has the basic locale, it won't do anything smart with the font. To the STB, it's just another font to be displayed using the standard locale until you tell the STB otherwise, and I'm not sure if you can do this if the locale isn't included in the middleware.
The only why round this is to check with ADB or Philips whether they could provide you with the appropriate locale for their STB.
Steve. -
Arabic numerals not displaying in Swing text components
On a test system setup with Windows NT Arabic version, we had problems entering Arabic numerics into Swing text components.
Other Arabic characters were displayed correctly, but numerals were all represented by Western characters ('0 to 9'). Even when using the "Alt-" method to enter the Unicode character codes via. the keypad, we still got incorrect characters.
When using the keypad to enter the code '\u0660' (Arabic "1"), the code sent to the text component was '\u2022' (Bullet).
We tried this on an English system and the same code was passed to the text component.
Does anyone have any suggestions as to what might be the cause of this problem ?
Thanks,
Brian...hello!
I am developing an arabic editor but i am unable to display the arbic numeric in swing text .Plz help me on this topic and send some code example on this topic.
I have another problem about events i.e how can i handle the beckspace event, enter event, and spaceevent?
plz send me mail .
Thanx for advance. -
Problem in displaying Arabic text in flash cs3/cs4
Hi All, I'm creating one website. I have to display dynamic xmlize arabic text in flash. I have done it using flash cs3/AS3. But problem is that when text displays in flash it is not rendering as expected. Some gaps comes in the characters. But when I open my xml in browser, arabic text displays correct.
Is there any way to do it in flash cs3 or Flash cs4 using player 9? It would be really great if anyone can give me solution on this. Thanks
ChandrakantYou have to do it yourself - I don't have a ready solution. Just look into documentation how StyleSheets are used and see what properties work best for you:
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/text/TextField.html
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/text/StyleSheet.html
Also, with embedded fonts you need to play with TextFormat settings and AntiAliasType
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/text/AntiAliasType.html
In addition, on my machine even if I don't emebed fonts - Arabic works in Arial, TImes and others. -
Arabic text displayed incorrectly on sites!
Arabic text characters are all connected one to another in a word, but FireFox displays the letters right, except they are disconnected and each letter is on its own, making it very difficult if not impossible to read.
What I used to do in the past is, pages that contain Arabic Text for me such as Facebook, I used to install IETAB2 and set facebook to always open with IETAB and then the text would display correctly.
The strange thing is, if you use IE, it would display the same garbage isolated Arabic letters, but the IETAB with IE7 emulation works like a charm.
With that said, recently, FF stopped displaying arabic text correctly even with IETAB2
But Google Chrome always works like a charm without the need for anything.
I have tried changing the encoding on the site but that doesn't help
Can anyone suggest anything please?
Google Chrome, Correct display of Arabic Text:
http://img148.imageshack.us/img148/9937/chromefc.png
FireFox with IETAB or without, same result:
http://img11.imageshack.us/img11/8855/firefoxlh.png
Anything other than UTF-8 will just display as jibberish.
But the problem with UTF-8 is that the Arabic letters are not linked one to the other, each one is seperated, makeing it very difficult to read.
What's even weirder is, I checked with Chrome, which displays Arabic Text just fine, and it is also using the UTF-8 encoding but it works!? Please help as I don't want to use Chrome :(The point is to see if disabling that setting temporarily and selecting some other fonts makes a difference.<br />
It is possible that the Lucida Grande font that you have isn't working properly. -
Display Arabic text in ScrollPane Component ?
hello,
i have RSS reader it's work fine with english but the problem
is arabic text don't display in RSS reader just english and help
about to display arabic text in ScrollPane component that component
reader info from xml file and display it ?
Regard,
Crimsonany idea ?
-
Displaying arabic text in jsp page
Hi,
Iam displaying some arabic values which will come from server in my jsp page.
but the problem when display the values its showing rubbish like �������������
when i select the view-->encoding from browser its showing arabic values..
i set <meta http-equiv="Content-Type" content="text/html; charset=windows-1256"> like this in my jsp page..
When i put the arabic text in normal .html page its working fine its displaying fine..
when iam calling jsp page iam getting above problem..
do i need to make any setting in server..iam using j2ee refrence server..
Regards,use UTF-8 for character encoding then arabic text will display
-
Problems with displaying dynamic Arabic text
We have a problem with a navigation system we are building
which has to be able to display dynamic Arabic text. We are pulling
in the Arabic text using XML. The problem we are having is that the
character are not displaying joined up where they should be (for
instance in the middle of words). Arabic characters have different
shaping according to the position they take up within a word. What
we are producing is apparently unreadable. Has anyone come accross
this problem before? Is it solveable?Hi:
Is there any possible chance that Adobe would do something to asist us Fl8 users with international character support.
Everyone has some work-around, except Abode, and they are all usually related to XML.
My setup is PHP (CMS supporting many languages) -> MySQL -> PHP -> Flash8 (Dynamic Text Fields) and the olpart that does not work is when I inject an extended character into the string - Flash stops displaying anything from that character on.
If Adobe has or did have some component / solution or anything other than the usual System.useCodePage = true (which never seems to actually work), please let me know.
Best Regards, -
Arabic texts display on Flash CS3
I've read through the forum on Adobe and other sites about
solution of Arabic texts on Flash. No doubt the Arabic texts can be
displayed perfectly in Dynamic text boxes(without embedding font),
but the problem is the policy of Dynamic text is whenever you
specify certain texts to have bold, italic or different color, but
all texts under same text box will be changed as well. It's not
freely as Static text, somemore you can't make animation like
masking, tweening using Dynamic text.
Now I am in the middle of searching high and low for solution
or extension to use Arabic texts freely on Static text without
compromising the limitation of animation.Anyone has idea on how to overcome this problem, please
generously help me by sending your solution to my email.
[email protected] Thanks
in advance! -
Hello All,
I have a sample arabic text, which i have stored into file. I want to read that file and display the arabic text on the screen.
If anyone has any idea please give me some inputs.
Thanks & Regards,
Faiz.Hi,
I have wrote some code for reading the text from file, and have also hardcoded some arabic text in TextField which shows up properly. But after reading the arabic text from file and setting the text to TextField the text is not shown properly its like ??????.
Please see the source code below.
* ReadText.java
* Created on December 2, 2009, 8:42 AM
package arabicsample;
import java.awt.Color;
import java.awt.ComponentOrientation;
import java.awt.Font;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
* @author faiz.chachiya
public class ReadText extends javax.swing.JFrame {
/** Creates new form ReadText */
public ReadText() {
initComponents();
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
txtArabic = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("Text");
txtArabic.setFont(new java.awt.Font("Lucida Sans", 0, 10));
txtArabic.setText("كيف حالك ");
jButton1.setText("Read");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtArabic, javax.swing.GroupLayout.PREFERRED_SIZE, 299, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(162, 162, 162)
.addComponent(jButton1)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtArabic, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(22, Short.MAX_VALUE))
pack();
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
readTextFromFile();
* @param args the command line arguments
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new ReadText().setVisible(true);
public void readTextFromFile() {
try {
final File file = new File(System.getProperty("user.dir") + "/conf/arabictext.txt");
final BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file), Charset.forName("utf-8")));
final String str = br.readLine();
//Charset.forName("utf-8").newEncoder().encode(in)
System.out.println("File text : " + str);
System.out.println(" " + txtArabic.getText());
System.out.println("Reading Process Completly Successfully.");
Font font = txtArabic.getFont();
System.out.println("GetFont " + font);
txtArabic.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
txtArabic.setBackground(Color.ORANGE);
txtArabic.setText(str);
final String UTF8Str = new String(str.getBytes());
System.out.println(UTF8Str);
} catch (UnsupportedEncodingException ue) {
System.out.println("Not supported : ");
} catch (IOException e) {
System.out.println(e.getMessage());
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JTextField txtArabic;
// End of variables declaration
}Please see the UTF-8 text file below. When i open the file, i see the text something similar in below.
??? ????One from UTF file from wordpad.
كيف حالكSo can you please correct where i am going wrong.
Thanks and Regards,
Faiz. -
Arabic text displaying as strange characters
When I copy Arabic text from MSQL 2005 to excel 2013, it is showing as strange characters.
But there is no issue when I copying Arabic text to excel 2010
How to fix this problem.Hi Dungun,
Thanks for posting in MSDN forum.
This forum is for developers discussing developing issues involve Excel application. Since the issue is relative to the end-user, I suggeste that you get more effecitve response from
Excel IT Pro Discussions forum.
The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us.
Thanks for your understanding.
Regards & Fei
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.
Maybe you are looking for
-
Can anybody help me resolve this Windows 8.1 Issue?
In summary, a couple of hours ago whilst surfing the internet, a message popped up on my screen and without doing anything told me that my computer was "installing Windows 8.1", and no matter what I did it wouldn't let me exit, and not being all that
-
Do I need to delete, then reload Firefox--it simply doesn't function now.
If my email opens, it takes more than a minute. Actually, the Gmail account is giving me the biggest share of problems. Basically, I can't use it. It's about 10 seconds behind the mouse, if it will work at all. I didn't have this problem until Firefo
-
OS X Server - Kerberos - Should I need to "Connect As" from client to server
Hi, I am setting up my first mac server - I have lots of expererince in Windows server, but mac newbie. I have set up a mac mini server - OS X Mountain Lion with Server DNS File Sharing Open Directory .private FQDN (server1.companyname.private) On th
-
Installation of NWDS & NWDI Hi I am looking at installing Netweaver Developer Studio. We presently have some servers available where we are contemplating installation 1. A PI 7.1 EHP1 Server 2. A SAP Enterprise Portal 7.0 I have some questions re
-
Hi, When we run the setup.exe (Disk 1) on windows machine, Installation Wizard does not appear. So we couldn't go ahead further steps for the installation. Please help us. Thanks, Jebastin.