Re: [PHP] Charset and filenames
"Jochem Maas" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Gustavo Lopes wrote: >> I appreciate your reply but I'm not satisfied. >> >> "Richard Lynch" <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >> >>>Gustavo Lopes wrote: >>> >>>>I'm building a script that makes a list of files available in a >>>>directory >>>>(PHP 4.3.10, Apache 2.0.53, windows, NTFS file system). The XHTML is >>>>served >>>>as ISO-8859-1. However, I'm having trouble in generating correct links >>>>for >>>>files with accents, etc. >>>>The problem is rawurlencode() appears to convert strings by translating >>> >>>I don't suppose there's any way to just rename the file... >> >> I don't want to rename any file, just change a link destination by >> encoding >> the filename differently. >> >> >>>You may be able to do the urlencode() and then un-do the %3E back to, err >>>whatever it was. >> >> What? Where did you get that %3E from? > > I think he was just typing off memory and quoted a different encoded > char... > my encoding battles are always a trail and error affair until 'it' > does what I want... but maybe these 2 functions may help you: > > http://nl2.php.net/manual/en/function.utf8-encode.php > http://nl2.php.net/manual/en/function.utf8-decode.php > > >> >> Gustavo Lopes >> Thank you, utf8_encode() is in fact the solution to my problem. A function $s -> htmlentities(rawurlencode(utf8_encode($s))) seems to be able to produce correct output for every file. Gustavo Lopes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Charset and filenames
I appreciate your reply but I'm not satisfied. "Richard Lynch" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Gustavo Lopes wrote: >> I'm building a script that makes a list of files available in a directory >> (PHP 4.3.10, Apache 2.0.53, windows, NTFS file system). The XHTML is >> served >> as ISO-8859-1. However, I'm having trouble in generating correct links >> for >> files with accents, etc. >> The problem is rawurlencode() appears to convert strings by translating > > I don't suppose there's any way to just rename the file... I don't want to rename any file, just change a link destination by encoding the filename differently. > You may be able to do the urlencode() and then un-do the %3E back to, err > whatever it was. What? Where did you get that %3E from? Gustavo Lopes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Charset and filenames
Hi I'm building a script that makes a list of files available in a directory (PHP 4.3.10, Apache 2.0.53, windows, NTFS file system). The XHTML is served as ISO-8859-1. However, I'm having trouble in generating correct links for files with accents, etc. The problem is rawurlencode() appears to convert strings by translating possible url unsafe characters into the corresponding %xx where xx is the due hexadecimal number in a specific charset (US-ASCII I think). Let's say there's a file called: Anatomia de superfície do tórax.pdf This file is rawurlencode()'d into: Anatomia%20de%20superf%EDcie%20do%20t%F3rax.pdf However, apache rejects this filename, returning a 403 (!) error. In fact, the simple ocurrence of, for instance, '%F3' in a url triggers this response. What in fact works (and Apache uses in its mod_autoindex listings) is: Anatomia%20de%20superf%c3%adcie%20do%20t%c3%b3rax.pdf Which represents the encoding in UTF-8 (?). One partial solution would be not to touch the filename and leave the encoding to the browsers, which works with IE6 (which leaves the filename untouched, apart from the spaces, which are transformed into %20 - apache accepts) and Opera7.54 (which surprisingly does the correct encoding), but not with Firefox, which performs the same transformation as rawurlencode(). What I need is a function that does the correct enconding, and - since once finished I shall move the script to another server - in case there be any platform specific issues, a solution that is as universal as possible. Thanks in advance Gustavo Lopes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php