[drupal-support] Charset problem

Vladimir Zlatanov vlado at dikini.net
Mon Feb 28 14:54:59 UTC 2005


On Mon, 2005-02-28 at 09:33 -0500, Steve Dondley wrote:
> To solve the problem, I changed the charset argument in the 
> drupal_set_header() function to iso-8859-1.  This took care of the 
> problem.  But now, of course, any UTF-8 encoded text shows  funky 
> characters.
> 
> What's the best way to get Drupal to output both UTF-8 and iso-8859-1 
> extended characters properly?
probably the best php way is using iconv - it is available for windows &
the *nix. I don't have a clue though how many of the hosting providers
support this extension by default.

may be a wrapper function similar to t() and l() could do the job -
something along the lines of if iconv is present the convert from
source_encoding to source_encoding otherwise leave intact.

function to_utf8($text, $enc='ISO-8859-1') {
  if (function_exists('iconv')) {
    return iconv($enc,'UTF8');
  }
  return $text;
}

Vlado




More information about the drupal-support mailing list