L
Louster
Guest
This place is pretty much dead, but I don't know any better place to post this, so...
I've found that, when translating text using the combination of strtr and get_html_translation_table, I get some weird... things going on when trying to convert '&' characters.
Ok, here's a code snippet:
The output is:
(Actually the output isn't that, but BW doesn't prevent the html codes from being changed into the characters they represent.)
The output is the same with HTML_SPECIALCHARS.
Is this supposed to happen? I can't see any link between specifying whether or not it translates quotes to codes and what it translates ampersands to... It doesn't make sense I tells ya!
I've found that, when translating text using the combination of strtr and get_html_translation_table, I get some weird... things going on when trying to convert '&' characters.
Ok, here's a code snippet:
Code:
$txttohtml = get_html_translation_table( HTML_ENTITIES );
printf( "%s\n", strtr( "&", $txttohtml ) );
$txttohtml = get_html_translation_table( HTML_ENTITIES, ENT_NOQUOTES );
printf( "%s\n", strtr( "&", $txttohtml ) );
$txttohtml = get_html_translation_table( HTML_ENTITIES, ENT_QUOTES );
printf( "%s\n", strtr( "&", $txttohtml ) );
The output is:
Code:
'
"
&
The output is the same with HTML_SPECIALCHARS.
Is this supposed to happen? I can't see any link between specifying whether or not it translates quotes to codes and what it translates ampersands to... It doesn't make sense I tells ya!