Convert encoding of given files from one encoding to another

iconv -f utf8 -t utf16 /path/to/file

4
By: imsaar
2009-12-01 21:02:58

These Might Interest You

  • Just for fun, I searched a simple way to encrypt some text. Simple base64 encoding seemed a good start so I decided to "amplify" encoding using repeted base64 encoding. Of course, this is not really secure but can be useful to hide datas to most part of humans ;). Do not hesitate to provide better solutions or else. Show Sample Output


    1
    str=password; for i in `seq 1 10`; do echo -e "$str\n"; str="$(base64 <<< $str)"; done
    n3wborn · 2011-10-04 18:01:54 0
  • converts encoding of a file to unix utf-8 useful for data files that contain what would be usable ascii text but are encoded as mpeg or some other encoding that prevents you from doing common manipulations like 'sed' Show Sample Output


    5
    ex some_file "+set ff=unix fileencoding=utf-8" "+x"
    nottings · 2009-02-19 16:23:21 1
  • One of my friends committed his code in the encoding of GB2312, which broke the build job. I have to find his code and convert.


    -1
    find . -name "*.java" -type f -perm +600 -print | xargs -I _ sh -c 'grep -q hexianmao _ && iconv -f gb2312 -t utf8 -o _ -c _ '
    Sunng · 2011-03-08 13:02:25 0
  • This is my first attempt at converting all HTML files to UTF-8 file encoding, including all subfolders. Theres probably a much more compact way to do it, but I'm quite proud of it with my windows background ;)


    8
    for x in `find . -name '*.html'` ; do iconv -f ISO-8859-1 -t UTF-8 $x > "$x.utf8"; rm $x; mv "$x.utf8" $x; done
    unixmonkey1789 · 2009-02-25 08:16:01 3

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: