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

Does anyone know how to print a £ in the command prompt in Windows? The code keeps giving me back an accented u or the literal ascii code. Thanks!

Replies are listed 'Best First'.
Re: About £ ...
by syphilis (Archbishop) on Jul 11, 2006 at 10:40 UTC
    Sounds like you're getting tripped up by the fact that Windows and the cmd.exe shell use different code pages.
    D:\pscrpt>perl -e "print ord('£')" 163 D:\pscrpt>perl -e "print chr(156)" £ D:\pscrpt>perl -e "print chr(163)" ú
    You need to convert between "cp1252" and "cp850" - for which you can use either Text::Iconv or (I believe) the Encode module. The latter, being a core module, is probably the "recommended" approach, though I've personally only ever used Text::Iconv.

    Cheers,
    Rob
Re: About £ ...
by prasadbabu (Prior) on Jul 11, 2006 at 10:05 UTC

    By using chr function you can do that.

    print chr(156);

    This will print '£' in the Command prompt in Windows. You would have used 163 instead of 156 which prints '£' in ascii file but in command Prompt you would have got accented u. So use 156 here for Command Prompt Output.

    Prasad