Reply to Re: Why appear " ? " ?

Your name:

Reply:


Posted by Janwillem Borleffs on 12/28/05 15:31

Bondo wrote:
> [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?
>

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_translation_table(HTML_ENTITIES);
$encoded = strtr(STRING_FROM_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_callback('/./s', 'filter', STRING_FROM_DATABASE);

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


JW

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация