Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > How does bea or tomcat encode filenames with special chars?

Reply
Thread Tools

How does bea or tomcat encode filenames with special chars?

 
 
mlv2312@terra.com.br
Guest
Posts: n/a
 
      12-13-2004
Hi,

I am experiencing problems with my href links containing filenames
with portuguese chars. For example, 'FUNDAMENTOS P REGULAMENTAÇÃO DA
CIDE.tif'.

However, if I open the listing files JSP on tomcat and click on the
right link, the same file opens. Then, I opened the source html code
generated for the listing files JSP, and I realized that the filename
was encoded as following:

'FUNDAMENTOS%20P%20REGULAMENTA%C3%87%C3%83O%20DA%2 0CIDE.tif'

I tried to encode the filename using the javascript function
'escape()', but the result was different:

'FUNDAMENTOS%20P%20REGULAMENTA%C7%C3O%20DA%20CIDE. tif'

I tried URLEncoder.encode, but the result was not the same...

Does anyone know which algorithm bea/tomcat use to encode special
chars?

Where can I find the appropriate information?

Best regards!

Marcelo
 
Reply With Quote
 
 
 
 
Tilman Bohn
Guest
Posts: n/a
 
      12-13-2004
On Sun, 12 Dec 2004 18:54:04 -0800, mlv231 wrote:

> Hi,
>
> I am experiencing problems with my href links containing filenames
> with portuguese chars. For example, 'FUNDAMENTOS P REGULAMENTAÇÃO DA
> CIDE.tif'.
>
> However, if I open the listing files JSP on tomcat and click on the
> right link, the same file opens. Then, I opened the source html code
> generated for the listing files JSP, and I realized that the filename
> was encoded as following:
>
> 'FUNDAMENTOS%20P%20REGULAMENTA%C3%87%C3%83O%20DA%2 0CIDE.tif'


This uses the UTF-8 encoded diacritics.

> I tried to encode the filename using the javascript function
> 'escape()', but the result was different:
>
> 'FUNDAMENTOS%20P%20REGULAMENTA%C7%C3O%20DA%20CIDE. tif'


While this uses ISO-8859-1[5].

> I tried URLEncoder.encode, but the result was not the same...


It would, but don't use the deprecated encode( String s ). If you
specify "UTF-8" as encoding, it will give you the first form, and if
you specify "ISO-8859-1", the second.

> Does anyone know which algorithm bea/tomcat use to encode special
> chars?


The same as your JS code, just with a different encoding.

> Where can I find the appropriate information?


http://www.unicode.org/
http://www.cl.cam.ac.uk/~mgk25/unicode.html
http://www1.tip.nl/~t876506/utf8tbl.html
http://java.sun.com/j2se/1.4.2/docs/...RLEncoder.html
http://java.sun.com/j2se/1.4.2/docs/...t/Charset.html

Cheers, Tilman

--
`Boy, life takes a long time to live...' -- Steven Wright

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to import filenames with special characters? inhahe Python 1 06-24-2008 03:52 PM
problem with filenames, Filenames and FILENAMES B.J. HTML 4 04-23-2005 08:13 PM
How to do special encode in string ? fowlertrainer@anonym.hu Python 3 06-23-2004 05:46 PM
How to do special encode in string ? fowlertrainer@anonym.hu Python 2 06-23-2004 03:45 PM
How to do special encode in string ? fowlertrainer@anonym.hu Python 1 06-22-2004 03:32 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57