CloneArmyCommander has asked for the wisdom of the Perl Monks concerning the following question:

I recently installed a unicode font in my computer and told the interpreter to "use utf8" but I get a message that tells me that the letter is too wide. Is there a module that I am forgetting to use, or do I need to reinstall unicode? I really do appreciate the help if anyone can tell me what I am doing wrong :).

Replies are listed 'Best First'.
Re: Using Unicode In Perl
by graff (Chancellor) on Apr 13, 2004 at 00:44 UTC
    If you got a warning like "Wide character in print...", this is a warning that happens in 5.8.x when the file handle you're printing to has not been set up to use unicode character semantics.

    I don't recall off-hand why this warning matters (when I triggered the warning just now, the character still printed as intended). Look at the perlunicode and perluniintro man pages to get more info on this.

    To avoid this warning, use the techniques described in the "PerlIO" man page, to open a file handle for ":utf8" i/o, or set the i/o protocol of an already-open file handle (like STDIN or STDOUT) to handle utf8 -- e.g.:

    $_ = "\x{0411}\n"; # Cyrillic capital letter BE binmode( STDOUT, ":utf8" ); print; # Look, ma, no warning!
      Thank you :)! With help from another monk I was able to get the characters to print, but still got the message. Thank you for telling me where I can look for answers :). I had searched the man pages before, but I didn't know what to look for. Thanks :)!
Re: Using Unicode In Perl
by halley (Prior) on Apr 12, 2004 at 16:26 UTC
    How to ask questions the smart way. What operating system? What "letter" or character? What message? What do you think wrote the message? Reinstall what component?

    --
    [ e d @ h a l l e y . c c ]

      Sorry about that :). OS: SuSE Linux; character: anything beyond the standers ISO charset; message: Character x is too wide; What do I think wrote the message: I have it narrowed down to either the Perl Interpreter or I do not have my computer comfigured properly and the shell is giving me the message; component to reinstall: unicode. I was hoping that by posting my message I could get some advice as to whether I'm writing my code incorrectly, or I have not configured my computer to work with unicode properly. I am in a situation where I need to write a script that uses characters that are not within the standard charset, and I assumed that, for my purposes, using unicode would be slightly more efficient that downloading a font with those characters and switching between the two :). Thanks for your help :), sorry I didn't have enough info :).
Re: Using Unicode In Perl
by iburrell (Chaplain) on Apr 12, 2004 at 19:02 UTC
    What version of Perl are you using? 5.8 has the best support for Unicode, 5.6 has some support but some bugs.

    How are you entering the Unicode character? "use utf8" does not do much in 5.8; it indicates that the source is in Unicode.

    It is much better to enter the character with the \xFEFF notation.

      Thanks :)! It worked :)! I still get warnings, but it prints anyway :). I appreciate the help :). It was enough to print the characters I needed :).