Sharing ideas

Solving problems

Gathering solutions

Exchanging thoughts

Ruby On Rails



Debian & Ubuntu
jQuery & CSS

Windows-1250 to Utf-8 Bash One-liner

There was a time when I worked with non utf-8 coded files quite a lot. They were usually saved using Windows-1250 encoding and obviously I wanted them in utf-8. I think I don’t need to tell you that you should probably use iconv for that, but there is also quite interesting tool called sponge that will allow you to pipe output of iconv to the very same file. In ubuntu it comes with packed called moreutils (also check out other apps it provides!). Install it with:

sudo apt-get install moreutils

Then in your .bashrc you can define something like:

function windows2utf() {
  iconv -f Windows-1250 -t utf-8 $1 | sponge $1

Reload the file with source .bashrc and try out your new, handy function :).