You are here: Re: Why appear " ? " ? « PHP Programming Language « IT news, forums, messages
Re: Why appear " ? " ?

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

 

Navigation:

[Reply to this 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

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация