• I uploaded a test file (57kb) named “test a?l’e?le?ve.jpg”. Once uploaded, it was renamed to test-a?le?le?ve.jpg – so the space was replaced and the " ' " was removed correctly, but the special characters were not replaced.

    I’m using WordPress 4.7.1, PHP 5.4.45.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author webvitaly

    (@webvitaly)

    What language are those chars from?

    Thread Starter Samuel

    (@sambody)

    French. Examples of french characters: éèêa??à?ù?.

    Small correction: the resulting name did not have any spacing (unlike what I wrote above, or what the WordPress comment system did to what I wrote), so that was not an issue. Just the special characters.

    • This reply was modified 7 years, 10 months ago by Samuel.
    Plugin Author webvitaly

    (@webvitaly)

    • Do you have French language installed on your computer?
    • What version of OS you you using?
    • What version of Browser are you using?
    Thread Starter Samuel

    (@sambody)

    – I’m on a Mac, OSX 10.11.6.
    – In english.
    – I use Firefox 50.1.

    I made a new test, using an image called test élève gar?on.png, with Chrome (version 55.0) this time, and I got the same result: spacing were correctly replaced with “-“, but special characters remained in the file name: test-élève-gar?on.png.

    Then I also switched my Mac computer to french, did that last test again in Firefox and Chrome, and it was the same result.

    I was facing the same issue. My guess is if the file is uploaded from Mac OS, the special characters are encoded in some proprietary Mac encoding – in my client’s case it was probably the Macintosh Central European encoding. In such case the current plugin’s replacement method will not work properly.

    I found the following solution.

    Change:

    $friendly_filename = preg_replace( array_keys( $chars_table ), array_values( $chars_table ), $filename );

    return strtolower( $friendly_filename );

    To:

    $friendly_filename = preg_replace( array_keys( $chars_table ), array_values( $chars_table ), $filename );

    $transliterate_filename = transliterator_transliterate(‘Any-Latin; Latin-ASCII; [\u0080-\u7fff] remove’, $friendly_filename);

    return strtolower( $transliterate_filename );

    @webvitaly In case you’d like to list me as a contributor, I’d be grateful:)

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Not working with special characters’ is closed to new replies.