decode encoded url [message #178675] |
Tue, 17 July 2012 05:47 |
cerr
Messages: 33 Registered: September 2010
Karma: 0
|
Member |
|
|
Hi,
I have a url that refers to a css background like:
url(./sites/all/themes/marinelli/img/backgrounds/men's_and_ladys&a mp;#039;_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?
Thanks for help!
Ron
|
|
|
Re: decode encoded url [message #178676 is a reply to message #178675] |
Tue, 17 July 2012 07:00 |
J.O. Aho
Messages: 194 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
cerr wrote:
> I have a url that refers to a css background like:
> url(./sites/all/themes/marinelli/img/backgrounds/men's_and_ladys&a mp;#039;_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?
The browser does it for you.
--
//Aho
|
|
|
Re: decode encoded url [message #178678 is a reply to message #178675] |
Tue, 17 July 2012 07:52 |
alvaro.NOSPAMTHANX
Messages: 277 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
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_ladys&a mp;#039;_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& amp;#039;_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.
--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
|
|
|
Re: decode encoded url [message #178689 is a reply to message #178678] |
Tue, 17 July 2012 13:04 |
cerr
Messages: 33 Registered: September 2010
Karma: 0
|
Member |
|
|
On Tuesday, July 17, 2012 12:52:53 AM UTC-7, Á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&#039;s_and_lad ys&#039;_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&#039; s_and_ladys&#039;_nights.jpg);';
> var_dump(mb_convert_encoding($html, 'UTF-8', 'HTML-ENTITIES'));
This doesn't work for me, I got some error:
<b>Parse error</b>: syntax error, unexpected '=', expecting ')' in <b> /homepages/9/d412202464/htdocs/drupal-7.14/sites/all/themes/marinelli/templ ates/html.tpl.php </b> on line <b>17</b><br />
>
> Then, it's pretty straightforward to create the file.
>
>
> If the string is supposed to be plain text already, I see no problem.
It wouldn't link a file called
men's_and_ladys'_nights.jpg nor
men's_and_ladys'_nights.jpg
>
>
> --
> -- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
> -- Mi sitio sobre programación web: http://borrame.com
> -- Mi web de humor satinado: http://www.demogracia.com
> --
|
|
|
Re: decode encoded url [message #178690 is a reply to message #178678] |
Tue, 17 July 2012 13:08 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
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_ladys&a mp;#039;_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& amp;#039;_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().
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: decode encoded url [message #178691 is a reply to message #178690] |
Tue, 17 July 2012 13:57 |
cerr
Messages: 33 Registered: September 2010
Karma: 0
|
Member |
|
|
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&#039;s_and_lad ys&#039;_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&#039; s_and_ladys&#039;_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...
|
|
|
Re: decode encoded url [message #178692 is a reply to message #178691] |
Tue, 17 July 2012 14:17 |
Erwin Moller
Messages: 228 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
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&#039;s_and_lad ys&#039;_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&#039; s_and_ladys&#039;_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?
Regards,
Erwin Moller
--
"That which can be asserted without evidence, can be dismissed without
evidence."
-- Christopher Hitchens
|
|
|
Re: decode encoded url [message #178693 is a reply to message #178690] |
Tue, 17 July 2012 15:18 |
Michael Fesser
Messages: 215 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
.oO(Jerry Stuckle)
> 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_ladys&a mp;#039;_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& amp;#039;_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().
This is not a URL encoding, but HTML character references.
Micha
--
http://mfesser.de/
Fotos | Blog | Flohmarkt
|
|
|
Re: decode encoded url [message #178694 is a reply to message #178692] |
Tue, 17 July 2012 14:56 |
Peter H. Coffin
Messages: 245 Registered: September 2010
Karma: 0
|
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&#039;s_and_lad ys&#039;_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&#039; s_and_ladys&#039;_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
|/)
|
|
|
Re: decode encoded url [message #178697 is a reply to message #178689] |
Tue, 17 July 2012 15:41 |
Christoph Becker
Messages: 91 Registered: June 2012
Karma: 0
|
Member |
|
|
cerr wrote:
> It wouldn't link a file called
> men's_and_ladys'_nights.jpg nor
> men's_and_ladys'_nights.jpg
That's a strange file name, but you can link to it in (X)HTML by
applying htmlspecialchars() to it, e.g.:
<a href="<?php echo
htmlspecialchars('men's_and_ladys'_nights.jpg') ?>">Men's and
Ladys' Nights</a>
--
Christoph M. Becker
|
|
|
Re: decode encoded url [message #178698 is a reply to message #178693] |
Tue, 17 July 2012 19:26 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 7/17/2012 11:18 AM, Michael Fesser wrote:
> .oO(Jerry Stuckle)
>
>> 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_ladys&a mp;#039;_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& amp;#039;_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().
>
> This is not a URL encoding, but HTML character references.
>
> Micha
>
Ah, you're right. I got caught up in the fact it was in a URL.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: decode encoded url [message #178699 is a reply to message #178689] |
Wed, 18 July 2012 08:29 |
alvaro.NOSPAMTHANX
Messages: 277 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
El 17/07/2012 15:04, cerr escribió/wrote:
> On Tuesday, July 17, 2012 12:52:53 AM UTC-7, Á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&#039;s_and_lad ys&#039;_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&#039; s_and_ladys&#039;_nights.jpg);';
>> var_dump(mb_convert_encoding($html, 'UTF-8', 'HTML-ENTITIES'));
>
> This doesn't work for me, I got some error:
> <b>Parse error</b>: syntax error, unexpected '=', expecting ')' in <b> /homepages/9/d412202464/htdocs/drupal-7.14/sites/all/themes/marinelli/templ ates/html.tpl.php </b> on line <b>17</b><br />
I wonder what code you are actually running, given that my snippet has
somehow grown HTML entities when you've quoted in your answer, but
that's a good old syntax error. Can't you really fix it?
>> If the string is supposed to be plain text already, I see no problem.
>
> It wouldn't link a file called
> men's_and_ladys'_nights.jpg nor
> men's_and_ladys'_nights.jpg
I beg your pardon? If the string is plain text, you don't have single
quotes anywhere: you have literal & characters.
--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
|
|
|