Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #6602 > unrolled thread
| Started by | cerr <ron.eggler@gmail.com> |
|---|---|
| First post | 2012-07-16 22:47 -0700 |
| Last post | 2012-07-17 15:26 -0400 |
| Articles | 12 — 8 participants |
Back to article view | Back to comp.lang.php
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
| From | cerr <ron.eggler@gmail.com> |
|---|---|
| Date | 2012-07-16 22:47 -0700 |
| Subject | decode encoded url |
| Message-ID | <1aba2dd9-81aa-40fd-8ea4-a8fdb966593c@googlegroups.com> |
Hi, I have a url that refers to a css background like: url(./sites/all/themes/marinelli/img/backgrounds/men's_and_ladys'_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
[toc] | [next] | [standalone]
| From | "J.O. Aho" <user@example.net> |
|---|---|
| Date | 2012-07-17 09:00 +0200 |
| Message-ID | <a6kgtbFf3eU1@mid.individual.net> |
| In reply to | #6602 |
cerr wrote: > I have a url that refers to a css background like: > url(./sites/all/themes/marinelli/img/backgrounds/men's_and_ladys'_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
[toc] | [prev] | [next] | [standalone]
| From | "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> |
|---|---|
| Date | 2012-07-17 09:52 +0200 |
| Message-ID | <ju35kn$h9d$1@dont-email.me> |
| In reply to | #6602 |
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'_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. -- -- 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 --
[toc] | [prev] | [next] | [standalone]
| From | cerr <ron.eggler@gmail.com> |
|---|---|
| Date | 2012-07-17 06:04 -0700 |
| Message-ID | <6096f9b4-6d9c-4472-b19f-dd6b8cc5ef20@googlegroups.com> |
| In reply to | #6605 |
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_ladys&#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/templates/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 > --
[toc] | [prev] | [next] | [standalone]
| From | Christoph Becker <cmbecker69@gmx.de> |
|---|---|
| Date | 2012-07-17 17:41 +0200 |
| Message-ID | <ju413l$hk6$1@speranza.aioe.org> |
| In reply to | #6616 |
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
[toc] | [prev] | [next] | [standalone]
| From | "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> |
|---|---|
| Date | 2012-07-18 10:29 +0200 |
| Message-ID | <ju5s4j$fg7$1@dont-email.me> |
| In reply to | #6616 |
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_ladys&#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/templates/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 --
[toc] | [prev] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2012-07-17 09:08 -0400 |
| Message-ID | <ju3o3o$mce$1@dont-email.me> |
| In reply to | #6605 |
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'_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(). -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ==================
[toc] | [prev] | [next] | [standalone]
| From | cerr <ron.eggler@gmail.com> |
|---|---|
| Date | 2012-07-17 06:57 -0700 |
| Message-ID | <2e93b482-35a7-4073-8638-ecb6b08c9b4a@googlegroups.com> |
| In reply to | #6617 |
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_ladys&#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...
[toc] | [prev] | [next] | [standalone]
| From | Erwin Moller <erwinmollerusenet@xs4all.nl> |
|---|---|
| Date | 2012-07-17 16:17 +0200 |
| Message-ID | <50057409$0$6981$e4fe514c@news2.news.xs4all.nl> |
| In reply to | #6618 |
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_ladys&#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
[toc] | [prev] | [next] | [standalone]
| From | "Peter H. Coffin" <hellsop@ninehells.com> |
|---|---|
| Date | 2012-07-17 09:56 -0500 |
| Message-ID | <slrnk0av9c.h39.hellsop@nibelheim.ninehells.com> |
| In reply to | #6619 |
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_ladys&#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
|/)
[toc] | [prev] | [next] | [standalone]
| From | Michael Fesser <netizen@gmx.de> |
|---|---|
| Date | 2012-07-17 17:18 +0200 |
| Message-ID | <qb0b08ho48ap8606seih63pg1r11nineqm@mfesser.de> |
| In reply to | #6617 |
.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'_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(). This is not a URL encoding, but HTML character references. Micha -- http://mfesser.de/ Fotos | Blog | Flohmarkt
[toc] | [prev] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2012-07-17 15:26 -0400 |
| Message-ID | <ju4e9p$90b$1@dont-email.me> |
| In reply to | #6620 |
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'_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(). > > 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@attglobal.net ==================
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web