[pmwiki-users] Issue with accented letter in link (with alternate page name in config)

Petko Yotov 5ko at 5ko.fr
Sun Oct 15 15:11:34 CDT 2017


On 2017-10-11 22:25, ABClf wrote:
> Just testing 2.2.103 on a new local installation (but probably not
> related to that version) : I'm facing an issue for links with accented
> french letter, when using dedicated alternate pagename in config.
> I believe the snippet given in Cookbook/AlternateNamingScheme is doing
> something I didn't expect.
> 
> In my config :
> 
> include_once("scripts/xlpage-utf-8.php");
> [...]
> $MakePageNamePatterns = array(
>     "/'/" => '',   # strip single-quotes
>     "/[^$PageNameChars]+/" => ' ',         # convert everything else to 
> space
>     '/((^|[^-\\w])\\w)/' => PCCF("return strtoupper(\$m[1]);"),
>     "/\\s+/" => '-');

When using international characters and UTF-8 the function strtoupper 
will not work well. The file scripts/xlpage-utf-8.php a working way to 
capitalize international characters, it may look complicated but you can 
simply copy the part you need:

   $MakePageNamePatterns = array(
       '/[?#].*$/' => '',                     # strip everything after ? 
or #
       "/'/" => '',                           # strip single-quotes
       "/[^$PageNameChars]+/" => ' ',         # convert everything else 
to space
       '/(?<=^| )([a-z])/' => 'cb_toupper',
       '/(?<=^| )([\\xc0-\\xdf].)/' => 'utf8toupper',
       '/ +/' => '_');

I copied this from the latest xlpage-utf-8.php into config.php (after 
including xlpage-utf-8) and changed the last line that strips spaces to 
replace them with an underscore character.

You shouldn't change or define in your config files any other page name 
variable like $PageNameChars, $GroupPattern, $NamePattern, 
$WikiWordPattern if you want your page names to contain international 
characters.

Note that this is from a very recent version 2.2.103 or 104; with an 
older version look at the older xlpage-utf-8.php.

Also note, if you change the $MakePageNamePatterns on an existing wiki, 
some links to existing pages may stop working. In the above example, by 
adding a new underscore character, links like [[Documentation Index]] 
and [[DocumentationIndex]] will point to two different pages (for 
example, the PmWiki/ documentation). You should decide if this is 
acceptable.

> [[mètre]] outputs links to : MèTre (same behavior with : é ; but works
> as expected with : ç)

Yes, this fixes this, and also [[les écoles]] (page name "Les_Écoles", 
uppercase accented characters, la classe).

Petko



More information about the pmwiki-users mailing list