strange char

Hi alli'm trying to write to a file an arabic Character but when i did ,the fils has squear sign not charwhat to do to solve the problem?
[159 byte] By [TheNewLeadera] at [2007-11-27 7:57:34]
«« IPv6
»» HELPP PLEASE
# 1
Chances are the program you use to view the file is incapable of rendering the characters.
floundera at 2007-7-12 19:39:26 > top of Java-index,Java Essentials,Java Programming...
# 2

> Hi all

>

> i'm trying to write to a file an arabic Character but

> when i did ,the fils has squear sign not char

>

> what to do to solve the problem?

First you have to identify what the problem is.

1) As flounder suggested you need to make sure you are displaying the character using a program that can and has a glyph that will show the character correctly.

2) How are you writing this character? Please post your relevent formatted code where you open this file and where you write this character to it.

cotton.ma at 2007-7-12 19:39:26 > top of Java-index,Java Essentials,Java Programming...
# 3

If you see question marks then you have an encoding error. If you see rectangular boxes then you are using a font that cannot render the characters. I believe that your "squear sign" is the rectangular box.

So the problem is with whatever you are using to look at the file. (There could also be a problem with your code that writes to the file, but that is less likely.)

DrClapa at 2007-7-12 19:39:26 > top of Java-index,Java Essentials,Java Programming...
# 4

I believe that your "squear sign" is the rectangular box.

That's right

here is the coding that i'm using

and when i try to use that rectangular box the program is confiused between words that have the same number of letters

String enc="UTF8"

Local loc= new Local("ar");

Wrt= new PrinterWriter( new BufferedWriter(new OutputStreamWriter(new FileOutputStream("file.txt"),

enc)));

how can i change the font ?

Message was edited by:

TheNewLeader

TheNewLeadera at 2007-7-12 19:39:26 > top of Java-index,Java Essentials,Java Programming...
# 5
any ideas?
TheNewLeadera at 2007-7-12 19:39:26 > top of Java-index,Java Essentials,Java Programming...
# 6
It's "UTF-8", not "UTF8". And what's a Local, do you mean Locale?
hunter9000a at 2007-7-12 19:39:26 > top of Java-index,Java Essentials,Java Programming...
# 7
yes they are utf-8 and locale
TheNewLeadera at 2007-7-12 19:39:26 > top of Java-index,Java Essentials,Java Programming...
# 8
but it still not showing the arabic char
TheNewLeadera at 2007-7-12 19:39:26 > top of Java-index,Java Essentials,Java Programming...
# 9
i don't know why now it is showing ? rather than the square boxes
TheNewLeadera at 2007-7-12 19:39:26 > top of Java-index,Java Essentials,Java Programming...
# 10
It's Unicode, man... :) here's a good primer. http://www.joelonsoftware.com/articles/Unicode.html
kevjavaa at 2007-7-12 19:39:26 > top of Java-index,Java Essentials,Java Programming...
# 11

Your problem is either that you're writing the file incorrectly, or that the program you use to view the file is not displaying it correctly.

For the first possibility, in that last code snippet you showed, you were using "UTF8" as the encoding, have you changed that to "UTF-8" yet? I'm pretty sure that makes a difference.

As for the second, what viewer are you using to display the files after you write them? Does it give you a way to specify what encoding to use when you open it?

hunter9000a at 2007-7-12 19:39:26 > top of Java-index,Java Essentials,Java Programming...
# 12
i'm using the UTF-8 for writing and am view my files in notebadi was able to read from an arabic file and view it but when i tried to write it gave me that strange chareven i know how to write to files since i use it for english
TheNewLeadera at 2007-7-12 19:39:26 > top of Java-index,Java Essentials,Java Programming...
# 13
> notebadFreudian Slip?
BigDaddyLoveHandlesa at 2007-7-12 19:39:26 > top of Java-index,Java Essentials,Java Programming...
# 14
notepadwhat is Freudian Slip?
TheNewLeadera at 2007-7-12 19:39:26 > top of Java-index,Java Essentials,Java Programming...
# 15
> notepad> > what is Freudian Slip? http://www.google.com/search?hl=en&q=Freudian+Slip
BigDaddyLoveHandlesa at 2007-7-21 22:25:28 > top of Java-index,Java Essentials,Java Programming...
# 16

> i'm using the UTF-8 for writing and am view my files

> in notebad

> i was able to read from an arabic file and view it

> but when i tried to write it gave me that strange

> char

>

> even i know how to write to files since i use it for

> english

Post the code you're currently using to write the file.

Notepad supports UTF-8, but you might have to force it to use it. Open Notepad, then choose File/Open. When you open the file, manually change the encoding from Unicode to UTF-8. I don't know if that makes a difference, but it's worth a shot.

hunter9000a at 2007-7-21 22:25:28 > top of Java-index,Java Essentials,Java Programming...
# 17

This is the code that i use for writing

PrintWriter out=

new PrintWriter(

new BufferedWriter(

new OutputStreamWriter(

new FileOutputStream("write.txt"),

enc)) );

TheNewLeadera at 2007-7-21 22:25:28 > top of Java-index,Java Essentials,Java Programming...
# 18
i did force the notepad to choose the UTF-8 but it still the same ;-(
TheNewLeadera at 2007-7-21 22:25:28 > top of Java-index,Java Essentials,Java Programming...
# 19
any ideas how to save the writing of arabic letters??/
TheNewLeadera at 2007-7-21 22:25:28 > top of Java-index,Java Essentials,Java Programming...
# 20

> This is the code that i use for writing

>

> PrintWriter out=

> new PrintWriter(

> new BufferedWriter(

> new OutputStreamWriter(

> new

> new

> FileOutputStream("write.txt"),

>

>

>enc)) );

That's where you create the PrintWriter, but where's the code where you actually write to it?

hunter9000a at 2007-7-21 22:25:28 > top of Java-index,Java Essentials,Java Programming...
# 21
i used the following for writingout.println(line);
TheNewLeadera at 2007-7-21 22:25:28 > top of Java-index,Java Essentials,Java Programming...