Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

iconv encoding conversion

  • 27-09-2006 04:27PM
    #1
    Registered Users, Registered Users 2 Posts: 90 ✭✭


    Hi,

    I'm trying to read data in from two files, but I'm not sure what encoding they use. Both are Japanese text, and when I open them up in firefox and check under View - Character Encoding, one supposedly uses 'UTF-8' and the other 'SHIFT_JIS'.

    Now I want both files (utf8File and shiftJISFile) to be encoded in SHIFT_JIS, so started up a prompt in unix and typed:

    iconv -f UTF-8 -t SHIFT_JIS utf8File > shiftJISFile

    The iconv command, should convert a file from one encoding set into antother, but I end up getting the error:
    iconv: illegal input sequence at position 0. This leads me to believe that Firefox has misinterpreted the file as being 'UTF-8'.

    Are there any clear ways of determining the encoding of a file, or does anyone know of another program to convert encodings?

    Thanks


Comments

  • Registered Users, Registered Users 2 Posts: 26 ast


    In the past I have found this very useful for this kind of work.

    http://www.babelstone.co.uk/Software/BabelPad.html


  • Registered Users, Registered Users 2 Posts: 1,476 ✭✭✭tred


    Hi,

    I'm trying to read data in from two files, but I'm not sure what encoding they use. Both are Japanese text, and when I open them up in firefox and check under View - Character Encoding, one supposedly uses 'UTF-8' and the other 'SHIFT_JIS'.

    Now I want both files (utf8File and shiftJISFile) to be encoded in SHIFT_JIS, so started up a prompt in unix and typed:

    iconv -f UTF-8 -t SHIFT_JIS utf8File > shiftJISFile

    The iconv command, should convert a file from one encoding set into antother, but I end up getting the error:
    iconv: illegal input sequence at position 0. This leads me to believe that Firefox has misinterpreted the file as being 'UTF-8'.

    Are there any clear ways of determining the encoding of a file, or does anyone know of another program to convert encodings?

    Thanks

    cat $FTMP | /usr/bin/iconv -f $INCODE -t $OUTCODE 2>/dev/null > $FTMP.jis

    i think u need to pass in an extra parameter after the file for null. This works for me fine.


Advertisement