PDA

View Full Version : TextField cannot disply Unicode character



livinglegends
1 Sep 2010, 4:12 AM
Hi,

In application, there is one utility, in which user can select file from Hard disk and after selecting file when user click on Submit button, it reads content of file and display data in text field.

Problem:

1. I have stored some data in notepad in Unicode format (At time of saving, selected Unicode in Encoding box)
2. When user select that file and click on submit button it display data in textfield as show in attached image.

So, How to display unicode data in textfield?

Thanks
LivingLegends

file:///C:/DOCUME%7E1/jshah/LOCALS%7E1/Temp/moz-screenshot.pngfile:///C:/DOCUME%7E1/jshah/LOCALS%7E1/Temp/moz-screenshot-1.png

Animal
1 Sep 2010, 4:16 AM
The font you are using does not have the glyphs for the codepoints.

Are you switching to a different font?

Animal
1 Sep 2010, 4:20 AM
But saving as "Unicode" does not have a meaning. Microsoft have done something weird there.

You can save using an encoding, but Unicode is just a standard which defines glyphs for codepoints.

livinglegends
1 Sep 2010, 4:56 AM
The font you are using does not have the glyphs for the codepoints.

Are you switching to a different font?

I have not set any font explicitly. it default font set by Extjs.

I think it doesnt related to font.

Because I have captured data sent by extjs on server and display it and it shows in different format.

Let say, there are 4 words in my file (all are in new line), test hello solution legal.

On server, it shows space between each character like "t e s t", "h e l l o" etc.

It means it read data in different format

Condor
1 Sep 2010, 5:09 AM
I have not set any font explicitly. it default font set by Extjs.

I think it doesnt related to font.

Because I have captured data sent by extjs on server and display it and it shows in different format.

Let say, there are 4 words in my file (all are in new line), test hello solution legal.

On server, it shows space between each character like "t e s t", "h e l l o" etc.

It means it read data in different format

This looks like UTF-16 interpreted as UTF-8 or ISO-8859-1.

Where is this data coming from? Did you specify the correct Content-type for this data?

livinglegends
1 Sep 2010, 5:21 AM
Let me explain you the flow in short.

1. User select file(in unicode format) from front end (extjs) and click on submit button.
2. That fill will be sent to server side where I read content, generate String
3. send string back to client
4. At client displaying this string in text field where I couldn't read it


I have changed my server side code to read content from file by encoding using UTF-16 and problem solved but now it crated problem to read non-unicode format file.

So, what can be common solution? Which encoding format should I use to read any kind of file?

Condor
1 Sep 2010, 5:41 AM
Your server needs to detect the Content-type of the submitted file (search - this has probably already been written by somebody for your particular server-side language).

livinglegends
1 Sep 2010, 6:21 AM
Your server needs to detect the Content-type of the submitted file (search - this has probably already been written by somebody for your particular server-side language).

I have written code to get content-type of file but for both the type of file (unicode and non-unicode), I am getting same content-type "text/plain".

I think I need encoding format or type for particular file. Do you have any idea how to get it?

I am searching but didn't get any thing.

Condor
1 Sep 2010, 6:32 AM
No, it's the charset part of the Content-type that's needed here.

livinglegends
1 Sep 2010, 6:53 AM
No, it's the charset part of the Content-type that's needed here.

When I have applied code to read content type of selected file, it return me application/octet-stream content type. So it couldn't read the content and utility stop to work and throws exception java.io.UnsupportedEncodingException: application/octet-stream

Condor
1 Sep 2010, 7:05 AM
No, the only way to determine the content type charset is to actually scan the data (check for BOM and/or UTF-8/16 conformancy).

livinglegends
1 Sep 2010, 7:11 AM
Do you have any idea how to get it in java?