How Convert Files Between Ascii and Utf-8

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/convert-files-ascii-utf-8/
PINTEREST
PINTEREST
INSTAGRAM

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 main.java

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.

LEARN MORE  Yum Usage

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
  • main.java is our source file to be converted
  • main-out.java 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.
RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/convert-files-ascii-utf-8/
PINTEREST
PINTEREST
INSTAGRAM

You may also like...

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)