[prev in list] [next in list] [prev in thread] [next in thread] 

List:       velocity-user
Subject:    Re: quick question: how to escape accented characters?
From:       Christoph.Reck () dlr ! de
Date:       2003-04-28 14:01:13
[Download RAW message or body]

David You wrote:
> Hi, A quick question. 
> How to encode accented characters such as "Á" for web display in Java?
> 
> I think there should be some existing funtions. But I can not find it.
> 
> thanks
> David

Character encodings have nothing to do with the template engine,
which just takes characters as input, replaces some content,
and then writes the resulting characters to the output.

You need to ensure that whatever encoding is written out by your
editor is read in properly by velocity, then what is written out by
velocity need to be understood by your browser.

Mostly ISO-8859-1, ISO-8859-9, or ISO-8859-15, as well as cp1251 and
UTF-8 are used for western characters.

Since the PostScript, SGML, and LaTeX there exist other spelled-out
forms for special characters. The SGML-form uses PS-names and is
useful for XML and HTML transfer: e.g. Á = Á = Á
more here:
   http://www.bbsinc.com/iso8859.html
(scroll down!) and:
   http://www.natural-innovations.com/wa/doc-charset.html
If you use 7-Bit ASCII (as with the apersand entities) you don't need
to care about the encodings used by the editor, nor the velocity
readers and writers (type Á in your editor).

Other posibilities are:

* Set the velocity reader and writer in the velocity.properties file:
     input.encoding = ISO-8859-1
     output.encoding = ISO-8859-1
   more here:
   http://jakarta.apache.org/velocity/developer-guide.html#Velocity%20Configuration%20Keys%20and%20Values

* Setup the HTTP-response object by calling in your application:
      res.setContentType("text/html;charset=ISO-8859-1");
    (could also be done in the template as the first line - before any spaces, etc.)

* Tell the browser what you wrote into the output stream within the
   <head> block:
     <meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">

* Write your character codes as apersand entities (using the decimal numeric
   character reference &#12345;). Please note that HTML 4.0 defines more
   entities that where available to HTML 3.2 (not all browsers will understand
   all the textual entities)


You might find some more usable information within the "The ISO 8859
Alphabet Soup" at:
   http://czyborra.com/charsets/iso8859.html
also see:
   http://www.kostis.net/charsets/
   ftp://dkuug.dk/i18n/charmaps/
   http://czyborra.com/utf/#UTF-8
   http://nwalsh.com/tex/texhelp/Plain.html

Have fun,
:) Christoph


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic