PDA

View Full Version : [ASP] How to deal with folder names with accented characters?


Clandestino
09-16-2008, 10:31 AM
Hello everybody,

I'm new to this forum, so please be kind with me. I've searched numerous resources on the web, including this one, and I couldn't find any answer or solution to my problem. Hence this humble request for assistance ;)

I have a little annoying issue with a script that has to deal with folders whose name may contain accented characters such as "é", "è", "â", "ê", ... The script displays thumbnails of pictures contained in those folders (and that part works very well).

I use the following method to access the folders:


...
g_folder = trim(request("gal"))
g_target = server.mappath("/images/galeries/" & g_folder & "/")
set fs = server.createObject("Scripting.FileSystemObject")
set fo = fs.GetFolder(g_target)
...


The "gal" querystring variable contains the name of a folder where some accented characters may be present (eg. "Prêt-à-porter", "Exemples et réalisations", ...). The script hangs on GetFolder() and returns a "Path not found" error.

All my data is encoded in UTF-8, as well as my content-type meta declaration. I've tried server.htmlencode, server.urlencode, character-by-character replacement with HTML entities, but nothing worked. I really hope I'll be able to get some help here, since this is driving me crazy. And unfortunately, moving to a database-driven solution is not an option... The user has to be able to populate the "galeries" folder and update its structure with a simple FTP application.

So thanks a million in advance!

ess
09-24-2008, 02:52 PM
I have come across this problem in the past whilst building a PHP based gallery...and ended up replacing any none-English characters into underscores "_"

For example, folder name "Prêt-à-porter" will be replaced with "Pr_t-_-porter"

Why...well, unfortunately I had to use urls to figure out which folder the user is browsing....and none-English characters don't work in URLs...so, even if you use a database, you will still have to think about URLs.

The solution that I had to use was to add a text file inside every folder which contained various useful information such as gallery name, number of images (instead of counting every time) among other useful information.