[Mediawiki-l] accents not appearing correctly

Hugh Prior mediawiki at localpin.com
Fri Feb 3 09:51:26 UTC 2006


I am trying to create wiki pages via program.  I have been partially 
successful, but I cannot seem to get passed problems of accented characters 
not appearing correctly.  Below I have a self-contained example.  It creates 
a page called "Page Test 1" fine, except that the page text, instead of 
reading as "Fédération" (with two "e"s with accents), I get complete junk 
for that part. In Internet Explorer it shows as a chinese character (!), and 
in Firefox I get two nasty blobs with question marks in.

What can I do to ensure the code-page translation stuff works correctly? 
There are a whole bunch of stuff for dealing with funny chars, but which to 
use, or how should I be pre-processing 'user' input?

Thanks!


Hugh Prior


<?

require_once("../includes/Article.php");
require_once("../includes/Title.php");
require_once("../includes/EditPage.php");
require_once("../includes/GlobalFunctions.php");


/**
 * Test page creation
 */
function pageCreate() {
   global $wgLoadBalancer;
   global $wgUser;

   // Create the page text
   $pageText = "Fédération";
   $wikiPageName = "Page Test 1";

   // Code adapted from "maintenance/InitialiseMessages.inc"
   $dbw =& wfGetDB( DB_MASTER );

   $title = new Title();
   $title = $title->newFromText($wikiPageName);

   $article = new Article( $title );
   $newid = $article->insertOn( $dbw, 'sysop' );

   $revision = new Revision( array(
   'page'      => $newid,
   'text'      => $pageText,
   'user'      => 0,
   'user_text' => "My user text",
   'comment'   => '',
   ) );
   $revid = $revision->insertOn( $dbw );
   $article->updateRevisionOn( $dbw, $revision );

   $dbw->commit();

}

// Call the page creation
pageCreate();

?> 






More information about the MediaWiki-l mailing list