Monthly Archives: March 2015

Writing weird unicode characters into mysql

Recently, I had to import a database of foreign names into MySQL. The names were written in farsi, like this شرکت ملی صنایع پتروشیمی (don’t ask me what that means, I have no idea)

Once imported into Mysql, it looked something like this “???? ?????????? ?? ???”. That’s bad. That’s MySQL saying it can’t recognize the characters.

So first, I made sure my table column could handle this character set. I changed the table column’s encoding to “UTF-8”. But this wasn’t enough.

Next I had to change the jdbc connection string from




And that should do it

Tagged , ,

What does ^M character mean and how do you import a csv into mysql with it?

This comes up for me from time to time and I always forget how to deal with it.

Basics, the ^M is a carriage return or newline symbol, but probably not one produced in your OS. You’ll want to switch it to your system’s default newline so it recognizes it.

Here’s how you might do that in vi/vim


It’s doing a replace with the carriage return /r with the system’s default carriage return /r.

Don’t question it, just do it!
But back up the original file just in case I’m wrong :/