can a browser read unicode?

S

Shinya Koizumi

Is it possible to send a unicode document
from servlet to the browser and the browser can
tell what kinda of language this document is written?

SK
 
J

John O'Conner

Shinya said:
Is it possible to send a unicode document
from servlet to the browser and the browser can
tell what kinda of language this document is written?

SK


The problem of language detection is quite difficult. Instead of forcing
a browser to use heuristics to determine document language, an HTML tag
can easily announce the same information. See the HTML "lang" tag:

http://www.w3.org/International/tutorials/tutorial-lang/

Regards,
John O'Conner
 
J

John C. Bollinger

Shinya said:
Is it possible to send a unicode document
from servlet to the browser and the browser can
tell what kinda of language this document is written?

That is the purpose of the "charset=" clause in an HTTP "Content-type:"
header. There are various ways to put such a header into your response,
but this is probably the easiest:

(in servlet code:)

response.setContentType("text/html; charset=UTF-8");

You do that before starting to write the actual response text. You then
ensure that you actually do encode the text in UTF-8, either by getting
and using the response's Writer, or by wrapping the response's
OutputStream in an OutputStreamWriter configured to use UTF-8.
 
A

Adam Maass

Shinya Koizumi said:
Is it possible to send a unicode document
from servlet to the browser and the browser can
tell what kinda of language this document is written?

Inferring a language from the characters contained in any given document is
difficult work, even for humans. One could write some heuristics to make
guesses, but those guesses will often be wrong. You don't say how much being
wrong matters for your application.

-- Adam Maass
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top