Too many underscores _ _ _ _ _ _ _

Too many underscores _ _ _ _ _ _ _

โดย Éric Bugnet -
Number of replies: 7
รูปภาพของDocumentation writers รูปภาพของPlugin developers รูปภาพของTranslators

Hi, all...

I've got this problem : I'm French, and in french language we are using accent (e, é, è, ê...).

I know that, in Internet language, we don't use accent for file name and directory name, and in Moodle all this accents are replace by underscores.

But I'm in a school, and when a teacher post a file named for exemple "l'été est passé", the file name is modified to "l__t__est_pass_".

That's a problem for orthography in school, and for readability.

Can't we replace "é" by "e" and not by "_", the file name will be "l_ete_est_passe" and will be more readable ???

It's not good for orthography, but a little more !

Thank's for your responses.

Eric

การประเมินโดยเฉลี่ย: -
In reply to Éric Bugnet

Re: Too many underscores _ _ _ _ _ _ _

โดย Petr Skoda -
รูปภาพของCore developers รูปภาพของDocumentation writers รูปภาพของParticularly helpful Moodlers รูปภาพของPeer reviewers รูปภาพของPlugin developers
There are many different encodings and national characters - PHP has no proper support for them sad I guess we will have to wait several years till PHP 6 or 7.

IMO it would be bad to solve only French problem, the global solution is quite complicated, though not impossible, but it would need much time, testing and the code would be rather slow.

If you want to do some custom hack, you can modify the cleaning function clean_filename() from lib/moodlelib.php, simply do the character replacement in the beginning of the function wink


skodak
การประเมินโดยเฉลี่ย: -
In reply to Petr Skoda

Re: Too many underscores _ _ _ _ _ _ _

โดย Éric Bugnet -
รูปภาพของDocumentation writers รูปภาพของPlugin developers รูปภาพของTranslators

Hi,

I think I should do that... (thanks for says me what function it is !)

I know that is not only a "Frenchy" problem, but perhaps it's possible to made that for the next Moodle version ? And not only for me and my country ??? I post here for explain my idea...

I prefer not modifying my Moodle and stay with the base Moodle ! (for upgrade...) but I think I'll try !

Ciao

Eric

การประเมินโดยเฉลี่ย: -
In reply to Petr Skoda

Re: Too many underscores _ _ _ _ _ _ _

โดย Éric Bugnet -
รูปภาพของDocumentation writers รูปภาพของPlugin developers รูปภาพของTranslators

Hi again...

It's done, and work :

I just change in function clean_filename() from lib/moodlelib.php

function clean_filename($string) {

/// Cleans a given filename by removing suspicious or troublesome characters

/// Only these are allowed:

/// alphanumeric _ - .

$string = eregi_replace("\.\.+", "", $string);

$string = eregi_replace("é", "e", $string);

$string = eregi_replace("è", "e", $string);

$string = eregi_replace("à", "a", $string);

$string = eregi_replace("ù", "u", $string);

$string = eregi_replace("â", "a", $string);

$string = eregi_replace("ô", "o", $string);

$string = eregi_replace("î", "i", $string);

$string = eregi_replace("ê", "e", $string);

$string = eregi_replace("û", "u", $string);

$string = eregi_replace("ä", "a", $string);

$string = eregi_replace("ö", "o", $string);

$string = eregi_replace("ï", "i", $string);

$string = eregi_replace("ë", "e", $string);

$string = eregi_replace("ü", "u", $string);

$string = eregi_replace("ç", "c", $string);

$string = preg_replace('/[^\.a-zA-Z\d\_-]/','_', $string ); // only allowed chars

$string = eregi_replace("_+", "_", $string);

return $string;

}

Just change this for other languages.

Eric

การประเมินโดยเฉลี่ย: -
In reply to Petr Skoda

Re: Too many underscores _ _ _ _ _ _ _

โดย Nicolas Martignoni -
รูปภาพของCore developers รูปภาพของDocumentation writers รูปภาพของParticularly helpful Moodlers รูปภาพของPlugin developers รูปภาพของTesters รูปภาพของTranslators
The function "dirify" (adapted from MovableType) will do it rather completely. See here: http://kalsey.com/2004/07/dirify_in_php/

Nicolas
การประเมินโดยเฉลี่ย: -
In reply to Nicolas Martignoni

Re: Too many underscores _ _ _ _ _ _ _

โดย Martin Dougiamas -
รูปภาพของCore developers รูปภาพของDocumentation writers รูปภาพของMoodle HQ รูปภาพของParticularly helpful Moodlers รูปภาพของPlugin developers รูปภาพของTesters
Thanks!  Good pointer!  I've included that convert_high_ascii() function as the first step in our function.
การประเมินโดยเฉลี่ย: -
In reply to Martin Dougiamas

Re: Too many underscores _ _ _ _ _ _ _

โดย Nicolas Martignoni -
รูปภาพของCore developers รูปภาพของDocumentation writers รูปภาพของParticularly helpful Moodlers รูปภาพของPlugin developers รูปภาพของTesters รูปภาพของTranslators
Martin,

Thank you for taking this problem in account wink

The perl script in attachment seems to have more unicode rules... but it's perl and I don't know how to convert it in PHP.

Cheers
Nicolas
การประเมินโดยเฉลี่ย: -