FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » decode encoded url
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: decode encoded url [message #178694 is a reply to message #178692] Tue, 17 July 2012 14:56 Go to previous messageGo to previous message
Peter H. Coffin is currently offline  Peter H. Coffin
Messages: 245
Registered: September 2010
Karma:
Senior Member
On Tue, 17 Jul 2012 16:17:45 +0200, Erwin Moller wrote:
> On 7/17/2012 3:57 PM, cerr wrote:
>> On Tuesday, July 17, 2012 6:08:05 AM UTC-7, Jerry Stuckle wrote:
>>> On 7/17/2012 3:52 AM, "???lvaro G. Vicario" wrote:
>>> > El 17/07/2012 7:47, cerr escribi???/wrote:
>>> >> I have a url that refers to a css background like:
>>> >> url(./sites/all/themes/marinelli/img/backgrounds/men's_and_lad ys'_nights.jpg);
>>> >>
>>> >> But now I'm wondering how I possibly should name that file or how i
>>> >> can decode this string to a url the filesystem & the browser can read?
>>> >
>>> > If the string is supposed to be HTML, you need to convert it into plain
>>> > text. It can be extremaly tricky becase the two most obvious functions
>>> > don't seem to work as advertised:
>>> >
>>> > http://es.php.net/manual/en/function.html-entity-decode.php
>>> > http://es.php.net/manual/en/function.htmlspecialchars-decode.php
>>> >
>>> > Another alternative is to use mb_convert_encoding():
>>> >
>>> > <?php
>>> > $html =
>>> > 'url(./sites/all/themes/marinelli/img/backgrounds/men' s_and_ladys'_nights.jpg);';
>>> >
>>> > var_dump(mb_convert_encoding($html, 'UTF-8', 'HTML-ENTITIES'));
>>> >
>>> > Then, it's pretty straightforward to create the file.
>>> >
>>> >
>>> > If the string is supposed to be plain text already, I see no problem.
>>> >
>>> >
>>>
>>> It's a URL, so the correct function to use would be urldecode().
>>
>> But when I name the file
>> men's_and_ladys'_nights.jpg (what erldecode() gives me), it doesn't work...
>>
>
>
> The string was 2 times encoded.
> Try to decode it again.
> echo urldecode("men's_and_ladys'_nights.jpg");
> gives
> men's_and_ladys'_nights.jpg
>
> I wonder why it was encoded like that?

Heh. You've SEEN what his editor does to quoting, and the lack of
concern exhibited over it... The double-encoding might well have been
caused just PASTING the single-encoded text.

--
_ o
|/)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: PHP Always Outputs
Next Topic: PHP Rear End Data Developer/ Contract/ Boston area
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Dec 01 03:44:01 GMT 2024

Total time taken to generate the page: 0.04605 seconds