Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #6621

Re: decode encoded url

From "Peter H. Coffin" <hellsop@ninehells.com>
Newsgroups comp.lang.php
Subject Re: decode encoded url
Date 2012-07-17 09:56 -0500
Organization A noiseless patient Spider
Message-ID <slrnk0av9c.h39.hellsop@nibelheim.ninehells.com> (permalink)
References <1aba2dd9-81aa-40fd-8ea4-a8fdb966593c@googlegroups.com> <ju35kn$h9d$1@dont-email.me> <ju3o3o$mce$1@dont-email.me> <2e93b482-35a7-4073-8638-ecb6b08c9b4a@googlegroups.com> <50057409$0$6981$e4fe514c@news2.news.xs4all.nl>

Show all headers | View raw


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, &quot;???lvaro G. Vicario&quot; wrote:
>>> &gt; El 17/07/2012 7:47, cerr escribi???/wrote:
>>> &gt;&gt; I have a url that refers to a css background like:
>>> &gt;&gt; url(./sites/all/themes/marinelli/img/backgrounds/men&amp;#039;s_and_ladys&amp;#039;_nights.jpg);
>>> &gt;&gt;
>>> &gt;&gt; But now I&#39;m wondering how I possibly should name that file or how i
>>> &gt;&gt; can decode this string to a url the filesystem &amp; the browser can read?
>>> &gt;
>>> &gt; If the string is supposed to be HTML, you need to convert it into plain
>>> &gt; text. It can be extremaly tricky becase the two most obvious functions
>>> &gt; don&#39;t seem to work as advertised:
>>> &gt;
>>> &gt; http://es.php.net/manual/en/function.html-entity-decode.php
>>> &gt; http://es.php.net/manual/en/function.htmlspecialchars-decode.php
>>> &gt;
>>> &gt; Another alternative is to use mb_convert_encoding():
>>> &gt;
>>> &gt; &lt;?php
>>> &gt; $html =
>>> &gt; &#39;url(./sites/all/themes/marinelli/img/backgrounds/men&amp;#039;s_and_ladys&amp;#039;_nights.jpg);&#39;;
>>> &gt;
>>> &gt; var_dump(mb_convert_encoding($html, &#39;UTF-8&#39;, &#39;HTML-ENTITIES&#39;));
>>> &gt;
>>> &gt; Then, it&#39;s pretty straightforward to create the file.
>>> &gt;
>>> &gt;
>>> &gt; If the string is supposed to be plain text already, I see no problem.
>>> &gt;
>>> &gt;
>>>
>>> It&#39;s a URL, so the correct function to use would be urldecode().
>>
>> But when I name the file
>> men&#039;s_and_ladys&#039;_nights.jpg (what erldecode() gives me), it doesn't work...
>>
>
>
> The string was 2 times encoded.
> Try to decode it again.
> echo urldecode("men&#039;s_and_ladys&#039;_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
 |/)

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

decode encoded url cerr <ron.eggler@gmail.com> - 2012-07-16 22:47 -0700
  Re: decode encoded url "J.O. Aho" <user@example.net> - 2012-07-17 09:00 +0200
  Re: decode encoded url "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2012-07-17 09:52 +0200
    Re: decode encoded url cerr <ron.eggler@gmail.com> - 2012-07-17 06:04 -0700
      Re: decode encoded url Christoph Becker <cmbecker69@gmx.de> - 2012-07-17 17:41 +0200
      Re: decode encoded url "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2012-07-18 10:29 +0200
    Re: decode encoded url Jerry Stuckle <jstucklex@attglobal.net> - 2012-07-17 09:08 -0400
      Re: decode encoded url cerr <ron.eggler@gmail.com> - 2012-07-17 06:57 -0700
        Re: decode encoded url Erwin Moller <erwinmollerusenet@xs4all.nl> - 2012-07-17 16:17 +0200
          Re: decode encoded url "Peter H. Coffin" <hellsop@ninehells.com> - 2012-07-17 09:56 -0500
      Re: decode encoded url Michael Fesser <netizen@gmx.de> - 2012-07-17 17:18 +0200
        Re: decode encoded url Jerry Stuckle <jstucklex@attglobal.net> - 2012-07-17 15:26 -0400

csiph-web