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


Groups > comp.lang.php > #6605

Re: decode encoded url

From "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid>
Newsgroups comp.lang.php
Subject Re: decode encoded url
Date 2012-07-17 09:52 +0200
Organization http://alvaro.es/
Message-ID <ju35kn$h9d$1@dont-email.me> (permalink)
References <1aba2dd9-81aa-40fd-8ea4-a8fdb966593c@googlegroups.com>

Show all headers | View raw


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.


-- 
-- 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
--

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