PHP, eh? Excellent.
I wrote this function to handle all my HTML entity conversions. It's mainly for people who copy-and-paste from Word documents (it converts curly quotes, ellipses, etc.), but you could use it like this:
PHP Code:
<?php
function html_encode($string)
{
// Converts a string containing special characters into the appropriate
// HTML entities
$trans_tbl = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES);
$trans_tbl[chr(133)] = '…';
$trans_tbl[chr(145)] = '‘';
$trans_tbl[chr(146)] = '’';
$trans_tbl[chr(147)] = '“';
$trans_tbl[chr(148)] = '”';
$trans_tbl[chr(149)] = '•';
$trans_tbl[chr(150)] = '–';
$trans_tbl[chr(151)] = '—';
$trans_tbl[chr(153)] = '™';
return strtr($string, $trans_tbl);
}
?>
<input type="text" name="article_title" value="<?php echo html_encode('Simon says, "stop!"'); ?>" />
Bookmarks