http://www.perlmonks.org?node_id=502145


in reply to trouble printing spanish characters

Where are your Spanish characters actually coming from? A data file? A web page? User input? How much do you know about your input data? (E.g. would you be able to say or find out what character encoding is being used when the data first comes into your script?)

If you're getting "line drawing characters" at the printer, your script might be sending the characters as utf8, and in that case, using the Encode module (and its "encode()" function), as shown in the first reply, is likely to be the right way to go -- though actually, assuming that perl is initially storing your strings internally as utf8, something like this would be simpler:

binmode( PRN, ":encoding(cp437)" );
By setting a PerlIO layer on your PRN file handle to apply the character encoding transfor for you (from utf8 to cp437), you don't need to do anything else -- you don't need "use Encode", you don't need any substitutions or other alterations of your string data.

Your statement of the problem was vague enough that I can't be sure this is the right answer, but this is a place to start, at least.