Liam Delahunty: Home Tips Web Contact
Recommended laptop
under £500
.

Think I deserve a present? See my Amazon Wish List

The remove_special_characters_basic.php page just does some htmlentities work. This page performs some additional work to try and remove the extended smart quotes etc from MS Word. This form will test some input and display the results both as the translated text and as the displayed results. The PHP code is further down the page if anyone is interested!

Enter your text here:
Encoded Output
Displayed Output

Firstly, please note that this page has a meta tag of:

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

if ($submit){
    $body = htmlentities("$my_text",ENT_COMPAT,ISO-8859-15);
    $body = ereg_replace(128, "&euro;", $body); // Euro symbol
    $body = ereg_replace(133, "&#133;", $body); // ellipses
    $body = ereg_replace(8226, "&#8243;", $body); // double prime
    $body = ereg_replace(8216, "&#039;", $body); // left single quote
    $body = ereg_replace(145, "&#039;", $body); // left single quote
    $body = ereg_replace(8217, "&#039;", $body); // right single quote
    $body = ereg_replace(146, "&#039;", $body); // right single quote
    $body = ereg_replace(8220, "&#034;", $body); // left double quote
    $body = ereg_replace(147, "&#034;", $body); // left double quote
    $body = ereg_replace(8221, "&#034;", $body); // right double quote
    $body = ereg_replace(148, "&#034;", $body); // right double quote
    $body = ereg_replace(8226, "&#149;", $body); // bullet
    $body = ereg_replace(149, "&#149;", $body); // bullet
    $body = ereg_replace(8211, "&#150;", $body); // en dash
    $body = ereg_replace(150, "&#150;", $body); // en dash
    $body = ereg_replace(8212, "&#151;", $body); // em dash
    $body = ereg_replace(151, "&#151;", $body); // em dash
    $body = ereg_replace(8482, "&#153;", $body); // trademark
    $body = ereg_replace(153, "&#153;", $body); // trademark
    $body = ereg_replace(169, "&copy;", $body); // copyright mark
    $body = ereg_replace(174, "&reg;", $body); // registration mark

// do it again to make it look right on the form
    $final = htmlentities("$body",ENT_COMPAT,ISO-8859-15);

}
// this is when we want to translate it back
if ($new_submit){
    $trans_tbl = get_html_translation_table (HTML_ENTITIES);
    $trans_tbl = array_flip ($trans_tbl);
    $my_text = strtr($my_text, $trans_tbl);
}

Share this!