How to fix UTF-8 support in a terminal

I found this while looking for a solution on how to transfer files with names containing accented characters from my Mac to a Win box. Here's another post with tips for some bugs.