1

I have a file in us-ascii format that I want to pass to UTF-8. I am trying to use the following code where hola.psv is my original file and hola1.psv is the new file in utf-8 format:

# getting encoding format
encoding=`file -i hola.psv | sed 's/=/ /g' |awk '{print $4}'`


# from original format to utf-8
# if file is already in utf-8 format then no tranformation is needed
if [ ! $encoding == "utf-8" ]; then
        iconv -f $encoding -t UTF-8//TRANSLIT hola.psv -o hola1.psv
else
        echo "Document is already in utf-8 format"
fi

However when I do a double check to see if my new file is in utf-8 format, I'm still getting the us-ascii format.

brenda
  • 656
  • 8
  • 24
  • 4
    UTF-8 and US-ASCII are exactly the same when you don't use any extended (>=0x80) characters. – that other guy Jan 28 '21 at 02:09
  • Is a BOM wanted in the utf-8? This is discussed [here](https://stackoverflow.com/questions/4364156/iconv-converting-from-windows-ansi-to-utf-8-with-bom). – user1934428 Jan 28 '21 at 07:30

0 Answers0