﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
1355	Internationalisation(charset) problems with FileField file names and core.db.backend.mysql	little	hugo	"1. The function django.utils.text.get_valid_filename() is not friendly for non-latin file-names
{{{
    s = s.strip().replace(' ', '_')
    return re.sub(r'[^-A-Za-z0-9_.]', '', s)
}}}
truncates file name to underscores only: {{{""__________.txt""}}} for example.

Let it retun a Unicode object of string s
{{{
    return unicode(s,'utf8')
}}}

Or make it possible to overload this function to end-programmer.

2. In django.core.db.backends.mysql.DatabaseWrapper in method cursor()
When you doing
{{{
            self.connection = Database.connect(**kwargs)
        cursor = self.connection.cursor()
        if self.connection.get_server_info() >= '4.1':
            cursor.execute(""SET NAMES 'utf8'"")
}}}
After 'set names ..' the charset of connection was changed. 
But self.connection.charset property (property of MySQLdb.connection) was not changed. It is always 'Latin1'
So, when i pass u""unicode national characters"" into database, MySQLdb tryed to convert it into Latin1 and exception raises

To fix it, i must set .charset propery manually:
{{{
...
            self.connection = Database.connect(**kwargs)
            self.connection.charset = 'utf8'
        cursor = self.connection.cursor()
        if self.connection.get_server_info() >= '4.1':
            cursor.execute(""SET NAMES 'utf8'"")
...
}}}

"	enhancement	new	Internationalization		normal				Unreviewed	0	0	0	0	0	0
