I'm trying to export some data from a MySQL database, but weird and wonderful things are happening to unicode in that table.

I will focus on one character, the left smartquote: “

When I use `SELECT` from the console, it is printed without issue:

```
mysql> SELECT text FROM posts;
+-------+
| text  |
+-------+
| “foo” |
+-------+

```

This means the data are being sent to my terminal as utf-8[0] (which is correct).

However, when I use `SELECT * FROM posts INTO OUTFILE '/tmp/x.csv' …;`, the output file is *not* correctly encoded:

```
$ cat /tmp/x.csv
â€œfooâ€

```

Specifically, the `“` is encoded with seven (7!) bytes: `\xc3\xa2\xe2\x82\xac\xc5\x93`.

What encoding is this? Or how could I tell MySQL to use a less unreasonable encoding?

Also, some miscellaneous facts:

* `SELECT @@character_set_database` returns `latin1`
* The `text` column is a `VARCHAR(42)`:
````

mysql> DESCRIBE posts;
+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| text  | varchar(42) | NO   | MUL |         |       |
+-------+-------------+------+-----+---------+-------+

````
* `“` encoded as utf-8 yields `\xe2\x80\x9c`
* `\xe2\x80\x9c` decoded as `latin1` then re-encoded as `utf-8` yields `\xc3\xa2\xc2\x80\xc2\x9c` (6 bytes).
* Another data point: `…` (utf-8: `\xe2\x80\xa6`) is encoded to `\xc3\xa2\xe2\x82\xac\xc2\xa6`

[0]: as smart quotes aren't included in any 8-bit encoding, and my terminal correctly renders utf-8 characters.