$db->sql_escape(utf8_clean_string($username))
-> utf8_clean_string($username)