How Convert Files Between Ascii and Utf-8 – POFTUT

How Convert Files Between Ascii and Utf-8

I have a java code and I want to convert it into Utf-8. How can I do it in console. By the way I have multiple files so it need to be do multiple conversion.

Getting Info About Character Set

We start by getting information about character set. We need to be sure files character set to convert accordingly.

  • file is very useful tool to get information about files like file type, encoding etc.
  • -i is used to get encoding information about file

List Supported Encodings of iconv

We will use iconv to conversation. But we need to know which encodings are supported by iconv .

Whooa there is a lot of options to use but we  think that ASCII and UTF-8 is enough for now.

Convert ASCII to UTF-8

We will convert  our java code by providing from and to encodings.

  • iconv is the tool to convert
  • -f us-ascii is the source file encoding type
  • -t UTF8 is target encoding type
  • is our source file to be converted
  • is new file encoded with UTF8

Convert Multiple Files Encoding

We can make things automated with simple bash scripting help.

  • *.java is source files to be converted with java extension
  • UTF8 is the destination encoding to be used.

Leave a Reply

Your email address will not be published. Required fields are marked *

Enjoy this blog? Please spread the word :)