WPIntell

Source evidence

Not working with special characters

Filenames to latin · support · 2017-01-18T20:17:00+00:00

complaintsentiment
mediumseverity
0.92relevance
5replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

6 / 26 rows with source links

23.1% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

20 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
Samuel unresolved
I uploaded a test file (57kb) named “test âl’élève.jpg”. Once uploaded, it was renamed to test-âlélè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. What language are those chars from? French. Examples of french characters: éèêâîçàôùû. 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 9 years, 4 months ago by Samuel . Do you have French language installed on your computer? What version of OS you you using? What version of Browser are you using? – 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:)

Comments

5 shown
webvitalii 2017-01-19T17:50:00+00:00

What language are those chars from?

Samuel 2017-01-19T19:38:00+00:00

French. Examples of french characters: éèêâîçàôùû. 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 9 years, 4 months ago by Samuel .

webvitalii 2017-01-23T04:49:00+00:00

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

Samuel 2017-01-24T19:38:00+00:00

– 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.

arteagacz 2017-02-20T23:52:00+00:00

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:)