MyBB Community Forums

Full Version: Character problems
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey, i have done an include for a custom pages in MyBB and I'm having trouble with accents on letters ...

For example :

Sami Lepistö becomes Sami Lepist�

Does someone knows why ?
You need to ensure that your pages you're including have the same character encoding (in the HTML) as the MyBB pages do - UTF-8 by default.

Moving to code modifications..
The thing is, I have 90something files to include as custom pages on my site.
They all are generated by a hockey simulator.

Is there a way to include them so I don't get character problems ?
I don't want (can't) change the code inside the html files.

Any idea out there ?
Ok ... i've created a script to put the character set in my pages :
if ( (isset($_GET['page'])) && (isset($pageOK[$_GET['page']])) ) {
     $fichier = $pageOK[$_GET['page']];   // Nous appelons le contenu central de la page
  } else {
     $fichier = '../includes/error.html';   // Page par défaut quant elle n'existe pas dans le tableau
  }
  
$var_nouvelles = file_get_contents($fichier);
 
$var_nouvelles = strtr($var_nouvelles, array('<title>' => 
    '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>'));

Which gives me this at the beginning of the page I include :
<html lang="fr">
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Eastside Hockey Manager - HTML Output</title>
</HEAD>
<body bgcolor=white background="default_back.gif" text=black link=blue vlink=blue>
<center><br><br>

But I still get :

grape T�rnstr�m instead of grape Tärntröm ...

Am I missing something !?
Ok, found the problem ... in my files the characters where hardcoded

é instead of &eacute;

So I did this :
$var_nouvelles = strtr($var_nouvelles, array('<title>' => 
    '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>',
'à' => '&agrave;', 
'À' => '&Agrave;', 
'á' => '&aacute;', 
'Á' => '&Aacute;', 
'â' => '&acirc;', 
'Â' => '&Acirc;', 
'ã' => '&atilde;', 
'Ã' => '&Atilde;', 
'ä' => '&auml;', 
'Ä' => '&Auml;', 
'å' => '&aring;', 
'Å' => '&Aring;', 
'æ' => '&aelig;', 
'Æ' => '&AElig;', 
'è' => '&egrave;', 
'È' => '&Egrave;', 
'é' => '&eacute;', 
'É' => '&Eacute;', 
'ê' => '&ecirc;', 
'Ê' => '&Ecirc;', 
'ë' => '&euml;', 
'Ë' => '&Euml;', 
'ì' => '&igrave;', 
'Ì' => '&Igrave;', 
'í' => '&iacute;', 
'Í' => '&Iacute;', 
'î' => '&icirc;', 
'Î' => '&Icirc;', 
'ï' => '&iuml;', 
'Ï' => '&Iuml;', 
'ò' => '&ograve;', 
'Ò' => '&Ograve;', 
'ó' => '&oacute;', 
'Ó' => '&Oacute;', 
'ô' => '&ocirc;', 
'Ô' => '&Ocirc;', 
'õ' => '&otilde;', 
'Õ' => '&Otilde;', 
'ö' => '&ouml;', 
'Ö' => '&Ouml;', 
'ø' => '&oslash;', 
'Ø' => '&Oslash;', 
'ù' => '&ugrave;', 
'Ù' => '&Ugrave;', 
'ú' => '&uacute;', 
'Ú' => '&Uacute;', 
'û' => '&ucirc;', 
'Û' => '&Ucirc;', 
'ü' => '&uuml;', 
'Ü' => '&Uuml;', 
'ñ' => '&ntilde;', 
'Ñ' => '&Ntilde;', 
'ç' => '&ccedil;', 
'Ç' => '&Ccedil;' ));