Re: Need program to convert UTF-8 -> Hex sequences

From: Doug Ewell (
Date: Tue Mar 04 2003 - 11:12:23 EST

  • Next message: Marco Cimarosti: "RE: Need program to convert UTF-8 -> Hex sequences"

    David Oftedal <david at start dot no> wrote:

    > Hm yes, so I see, but I should have been more specific, I actually
    > need an app that can do this automatically, either in ansi C, Perl,
    > or a Linux binary. I need to call it from a script, so it's got to
    > happen automatically. The find-replace to add the 0x I can do, so
    > it's just a matter of converting glyphs to codes.

    From ANSI C, simply write:

        printf("0x%04X ", c);

    for any Unicode character c. The pattern "%04X" writes the value of its
    argument in uppercase hex, using at least 4 hex digits (expanding to
    more than 4 or adding leading zeros as necessary).

    I added a space after the "X" to handle multi-character output (e.g.
    0x00E6 0x00F8 0x00E5), as you said you needed.

    -Doug Ewell
     Fullerton, California

    This archive was generated by hypermail 2.1.5 : Tue Mar 04 2003 - 12:05:31 EST