Click to See Complete Forum and Search --> : Special Characters and Image name
bsarlo
01-23-2005, 05:31 AM
Hi all.
I've searched through the web and couldn't find the solution to my problem.
I have a site that works with php, mod_rewrite, apache, and linux.
Whenever I try to see a picture which the name has special characters, then it wont display it.
This are the tests I've made.
The file name is Espa%F1a.jpg
When I write directly to the browser url bar, this are the results:
When I point to Espa%25F1a.jpg, It shows the file.
When I point to Espa%F1a.jpg, it doesn't work and shows up Error 404
And when I point to España.jpg it rewrites the url to Espa%F1a.jpg and shows an Error 404
Any help will be much appreciated.
laserlight
01-23-2005, 10:47 AM
The reason is simple: %25 is the urlencoded form for the percent symbol, %
When "Espa%25F1a.jpg" is used, the browser converts this to "Espa%F1a.jpg" and uses that.
The solution probably involves using rawurlencode() or urlencode().
bsarlo
01-23-2005, 04:05 PM
Hey laserlight, thanks for your reply, but I think I understand this part, but just can't understand why, the "%" special character is represented with itself plus "F1"... I just can't understand this.
Anyway, here are other tests I've made so maybe it's more clear what the problem could be, but I still cant understand it.
For example, if I have now a file called "Blumensträußen test.jpg" (with special characters and a space), here are the results from my tests:
If I enter the url Blumensträußen test.jpg into the address bar, it will translate it and show the image correctly, and that will be "Blumenstr%E4u%DFen%20test.jpg"
Now our problem. The same wont work within an html page. If I call for an image "Blumenstr%E4u%DFen%20test.jpg" it wont show it, or even calling "Blumensträußen test.jpg" wont do it, and here is where my project is stuck till I find a way out... :S
thanks again for the support.
laserlight
01-24-2005, 05:37 AM
but just can't understand why, the "%" special character is represented with itself plus "F1"
The '%' character is represented as %25 in urlencoded form.
"Espa%F1a.jpg" in urlencoded form is "Espa%25F1a.jpg"
If you did not urlencode this filename, then %F1 would be interpreted as the character represented by %F1 in urlencoded form, hence the filename used would be incorrect.
Interestingly, the urlencoded form of "España.jpg" appears to be "Espa%C3%B1a.jpg", not "Espa%F1a.jpg", at least to me.
If I call for an image "Blumenstr%E4u%DFen%20test.jpg" it wont show it, or even calling "Blumensträußen test.jpg" wont do it
That's unusual, as far as I can see the rawurlencoded form is correct.
I dont have any way to test your problem, so you'll have to think about it and construct your own tests, or maybe post some code.
PHP Builder
Copyright WebMediaBrands Inc. All Rights Reserved.