Why appear " ? " ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bondo

    #1

    Why appear " ? " ?

    [Apache 2, Php 5, MySQL 5, myODBC via ADOdb]

    On window works all correctly.

    On linux (RedHat) in some pages appear a " ? " char on video.
    In HTML source this char IS NOT PRESENT :(.

    Some ideas?
    That's a problem of charset?

  • Janwillem Borleffs

    #2
    Re: Why appear " ? " ?

    Bondo wrote:[color=blue]
    > [Apache 2, Php 5, MySQL 5, myODBC via ADOdb]
    >
    > On window works all correctly.
    >
    > On linux (RedHat) in some pages appear a " ? " char on video.
    > In HTML source this char IS NOT PRESENT :(.
    >
    > Some ideas?
    > That's a problem of charset?
    >[/color]

    Yes. It might be something simple like "ë", but it's also possible that
    someone copy and pasted the contents of a Word document containing control
    characters into the database.

    In the first case, you can do something as the following to translate these
    characters to their appropriate HTML entity:

    $trans = get_html_transl ation_table(HTM L_ENTITIES);
    $encoded = strtr(STRING_FR OM_DATABASE, $trans);

    When producing XHTML, you could also set the encoding to UTF-8 or any other
    appropriate encoding, e.g. with:

    <?xml version="1.0" encoding="utf-8"?>

    Most browsers enable you to set the encoding manually, which enables you to
    figure out the correct value.

    In the second case, you could remove all characters outside the US-ASCII
    character range, e.g. with:

    function filter($c) {
    return ord($c[0]) <= 126 ? $c[0] : '';
    }

    $filtered = preg_replace_ca llback('/./s', 'filter', STRING_FROM_DAT ABASE);

    Also, lookup character encoding/decoding in the MySQL manual @
    http://www.mysql.com/


    JW


    Comment

    Working...