tokyotech / monarch-flex

Automatically exported from code.google.com/p/monarch-flex
0 stars 0 forks source link

Post time can't handle HTML entities #32

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I thought I fixed this by decoding the entities, but it doesn't work. It's
truly bizarre how I can't convert a pregmatch result, but works perfectly
fine when I pass it the string. Look at the output of monarch_server/temp.php:

$result[1][0] = Apr 10, 8:19 am
html_entity_decode($result[1][0]) = Apr 10, 8:19 am
strtotime(html_entity_decode($result[1][0])) =
strtotime("Apr 10, 8:19 am") = 1239369540

Original issue reported on code.google.com by tokyotech on 13 Apr 2009 at 6:24

GoogleCodeExporter commented 9 years ago
Copied from PHP docs for html_entity_decode:
:::::::
Note: You might wonder why trim(html_entity_decode(' ')); doesn't reduce the
string to an empty string, that's because the ' ' entity is not ASCII code 32
(which is stripped by trim()) but ASCII code 160 (0xa0) in the default ISO 
8859-1
characterset.
:::::::

' ' is not replaced with a space by html_entity_decode so we need to replace 
the
characters that are added with a space. The ASCII 160 character makes sense but 
I'm
not entirely sure how the ASCII 194 character appears. See 
'monarch-server/temp.php'
(newest version).

Original comment by andrewps...@gmail.com on 13 Apr 2009 at 11:35

GoogleCodeExporter commented 9 years ago
So what's it replace   with? I saw it being converted to a space in the page
source.  So it looks like a space but really isn't?

// works
echo strtotime(str_replace(' ', '', $result[1][0]));

// fails
echo strtotime(str_replace(' ', '', html_entity_decode($result[1][0])));

Original comment by tokyotech on 14 Apr 2009 at 12:08

GoogleCodeExporter commented 9 years ago
I have seen a weird character (rectangle with numbers in it) in the string 
outputted
by html_entity_decode. I think the simple hack of replacing   is the best we 
can
do right now.

Original comment by andrewps...@gmail.com on 16 Apr 2009 at 1:39

GoogleCodeExporter commented 9 years ago
hacked with only   replacement.

Original comment by tokyotech on 20 Apr 2009 at 5:56