note 88126 rejected from function.htmlspecialchars-decode by danbrown
| From: | danbrown@php.net | Date: | Mon, 12 Jan 2009 16:24:34 +0000 |
| Subject: | note 88126 rejected from function.htmlspecialchars-decode by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-149098@lists.php.net to get a copy of this message | ||
Note Submitter: steven at gsm-software dot net
----
Not sure if this is a bug so just posting it as a note:
When you have data in your (Mysql) db encoded with htmlspecialchars() and you want to retrieve the
data for example to create a csv / xls file and the file should contain the decoded data, you
can't use htmlspecialchars_decode() as this function creates some 'invisible'
newlines which messes up the columns in your file (doesn't matter if you use tab delimited or
';' delimited).
I tried filtering the data before and after the use of htmlspecialchars_decode() using:
str_replace("\n","", $col1);
str_replace("\r\n","", $col1);
but this does not make any difference.
I solved the problem by manually decoding everything that htmlspecialchars() encodes using
str_replace() and everything works fine without any strange invisible newlines
b.r.
(ps Running php5; no similiar bug reports found in bug search)