Page 1 of 1

Does -encoding work?

Posted: 2008-05-13T05:58:48-07:00
by Jaclaw
I have IM 6.4.1 installed on my Debian server and have serious problems with writing national/Unicode characters with any functions.
Whatever I write in encoding param, it doe's not matter. The output stays the same.

I tried to convert UTF-8 formated text from this example:
http://www.cl.cam.ac.uk/~mgk25/ucs/exam ... 8-demo.txt
with this command:

Code: Select all

convert -background lightblue -encoding 'Unicode' -fill blue label:@UTF-8-demo.txt test.gif
...and the effect is always like that:
Image



A simple example from:
http://www.imagemagick.org/Usage/text/#unicode

Code: Select all

 env LC_CTYPE=en_AU.utf8 \
    printf "\u2018single\u2019 - \u201Cdouble\u201D" | \
      convert -background lightblue -fill blue -pointsize 36 \
              label:@-  label_quotes.gif
produces:
Image

What do I do wrong?

Re: Does -encoding work?

Posted: 2008-05-27T00:51:55-07:00
by anthony
It looks as if your "printf" command did not convert \u unicode charcater codes to actual unicode characters. You will need to find some way to do this.

Hmmm if you have perl on you system its printf's should handle unicode generation...

For example...

Code: Select all

   perl -e 'binmode(STDOUT, ":utf8"); \
            print "\x{6d4b}\x{8bd5}\x{7528}\x{7684}\x{6c49}\x{5b57}\n";'

   perl -e 'binmode(STDOUT, ":utf8");
     print pack("U*", 0x6d4b, 0x8bd5, 0x7528, 0x7684, 0x6c49, 0x5b57), "\n";'
Pipe the output of one of the above commands into the IM convert command. You also need a unicode font too, that has those characters in it. Such as the "SimSun" chinese font.