Re: MIME-aware recode or iconv?

From: jcowan@reutershealth.com
Date: Thu Jan 15 2004 - 15:23:23 EST

  • Next message: John Hudson: "Samaritan shin symbol (Was: Aramaic unification and information retrieval)"

    Frank da Cruz scripsit:

    > Is anybody aware of a Unix stdin/stdout application (suitable for
    > piping) that converts a text stream from one character encoding to
    > another based on its MIME headers (as you would find, for example, in
    > an email message)?

    The following script is not bulletproof, but it should work in most cases:

    #!/bin/sh
    TMP=/tmp/mime-recode-$$
    cat >$TMP
    CHARSET=`perl -ne 'print "$1\n" if /^Content-Type:.*charset="([^"]*)/i' <$TMP`
    iconv -f $CHARSET <$TMP

    -- 
    Winter:  MIT,                                   John Cowan
    Keio, INRIA,                                    jcowan@reutershealth.com
    Issue lots of Drafts.                           http://www.ccil.org/~cowan
    So much more to understand!                     http://www.reutershealth.com
    Might simplicity return?                        (A "tanka", or extended haiku)
    


    This archive was generated by hypermail 2.1.5 : Thu Jan 15 2004 - 16:08:41 EST