Forum Replies Created

Viewing 1 replies (of 1 total)
  • Hello all. I found out the solution.

    Short answer.
    Put the following line in the beginning of functions.php of your theme:
    setlocale(LC_CTYPE, 'ru_RU.utf8');

    Long answer.
    1. wp-content/plugins/contact-form-7/modules/file.php line 162
    Here is the chain of functions that format the name of file

    $filename = $file['name'];
    $filename = wpcf7_canonicalize( $filename );
    $filename = sanitize_file_name( $filename );
    $filename = wpcf7_antiscript_file_name( $filename );
    $filename = wp_unique_filename( $uploads_dir, $filename );

    Firstly, wpcf7_canonicalize() returns “??????????” instead of filename.
    Secondly, sanitize_file_name() returns “1”.
    Here we are. Obviously, promblem is in wpcf7_canonicalize() function:

    function wpcf7_canonicalize( $text ) {
    	if ( function_exists( 'mb_convert_kana' )
    	&& 'UTF-8' == get_option( 'blog_charset' ) ) {
    		$text = mb_convert_kana( $text, 'asKV', 'UTF-8' );
    	}
    
    	$text = strtolower( $text );
    	$text = trim( $text );
    	return $text;
    }

    Specifically, the problem is the strtolower() function, it returns “????????”, because locale LC_CTYPE is “ru_RU.CP1251” (in my case). It can be checked with setlocale(LC_CTYPE, 0); So, setting UT8-8 solves the problem:
    setlocale(LC_CTYPE, 'ru_RU.utf8');

Viewing 1 replies (of 1 total)