No, not an exact reverse, but a function which could take arbitrary input with HTML entities in it and convert that input to a normal string. The input would not neccesarily need to come from the htmlentities function. It could come from any arbitrary HTML code, including hand-coded or generated by some other means. I realize that most people would probably use the word-based entities, but why not support the numeric ones too? To do this in PHP would be possible, but the the C function is also at least a factor of 10 to 60 times faster already. Granted, it needs locale support etc, but that shouldn't slow it down too much if it were added.
-Brad Rasmus Lerdorf wrote: > But then we are not talking about the reverse of htmlentities because > htmlentities() would never create   > > On Tue, 26 Feb 2002, Brad Fisher wrote: > > > Not as trivial as you make it seem... > > > > ------------- Consider the following code: ----- > > > > $data = "This is & some   text"; > > $trans = get_html_translation_table(HTML_ENTITIES); > > $trans = array_flip($trans); > > $data2 = strtr($data,$trans); > > echo "Original data is:\n"; > > echo "$data\n\n"; > > echo "New data is:\n"; > > echo $data2; > > > > -------------- The output is: ------------------ > > > > Original data is: > > This is & some   text > > > > New data is: > > This is & some   text > > > > ----------------------------------------------- > > > > Yes, the & entity was handled properly, but the   entity was > > > not. That is a valid entity AFAIK. In addition to the speed > > improvement of having a native C version of this function, I think > it > > would be worthwhile to have built-in. > > > > -Brad > > > > > > Rasmus Lerdorf wrote: > > > > > Reversing htmlentities is trivial. I don't think it needs a > special > > > function. > > > > > > Simply do: > > > > > > $trans = get_html_translation_table(HTML_ENTITIES); > > > $trans = array_flip($trans); > > > $data = strtr($data,$trans); > > > > > > -Rasmus > > > -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php