Question: I'm trying to invert meta attributes (content and name) by using a jQuery function but ONLY if the meta content starts with "some"

```
<meta name="abc" content="something"/>
<meta name="def" content="somewhere" />

```

I've tried this function :

```
<script>
$('meta').ready(function(){
var a_metaname = $(this).attr("name");
var a_metacontent = $(this).attr("content");

if(a_metacontent^="some") {
$('head').append("<meta name="+ a_metacontent +" content="+ a_metaname +" />");

}
 });
</script>

```

but it doesn't invert the couple name/content for each meta.

How could I improve the function ? Thanks !

Answer: 
Reading through the traceback, it appears that the log module is attempting to encode the message before it writes it. The message is presumed to be an ASCII string, which it can't be because it contains UTF-8 characters. If you convert your message to Unicode before passing it to the logger it might work.

```
    log.debug(u"process_clusters: From CSV: %s", i)

```

Edit, I noticed your parameter string was already decoded to Unicode so I updated the example accordingly.

Also based on your latest edit, you probably want to use a Unicode string in your setup:

```
handler.setFormatter(logging.Formatter(u'[%(levelname)s] %(message)s'))
                                     --^--

```
All the string vs. unicode in Python2 is a mess... fortunately corrected in Python3. But assuming that moving to Python3 is not an option, here it goes.

As I see it, there are two options when using `logging` with respect to encodings:

1. Open the file as binary and use all the strings as byte-strings.
2. Open the file as text and use all the strings as unicode-strings.

Any other option is doomed!

The problem is that you specify encoding `"utf-8"` when opening the File but your russian text is a unicode string.

So you can do one (just one) of the following:

1. Open the file in binary, that is, remove the `"utf-8"` argument from the `FileStream` construction.
2. Convert all the relevant texts to unicode-strings, that includes the arguments to `log.debug` and the one to `logging.Formatter`.