How can I display Extended ASCII Codes characters in Perl?

谁说胖子不能爱 提交于 2019-12-07 04:23:17

问题


How to display 192 character symbol ( └ ) in perl ?


回答1:


What you want is to be able to print unicode, and the answer is in perldoc perluniintro.

You can use \x{nnnn} where n is the hex identifier, or you can do \N{...} with the name:

perl -E 'say "\x{2514}"; use charnames; say "\N{BOX DRAWINGS LIGHT UP AND RIGHT}"'



回答2:


To use exactly these codes your terminal must support Code Page 437, which contains frames. Alternatively you can use derived CP850 with less boxing characters. Such boxing characters also exist as Unicode Block Elements. The char which you want in perl is noted as \N{U+2514}. More details in perlunicode




回答3:


That looks like the Code page 437 encoding. Perl is probably just outputting bytes that you give it. And your terminal is probably expecting UTF8.

So you need to decode it to Unicode, then re-encode it in UTF-8.

EDIT: Correct encoding.




回答4:


As usual, Jon Skeet nails it: the 192 code is in the "extended ASCII" range. I suggest you follow @Douglas Leeder's advice, but I'm not sure which encoding www.LookupTables.com is giving you; ISO-8859-1 thinks 192 maps to "À", and Mac OS Roman thinks its "¿".



来源:https://stackoverflow.com/questions/3753055/how-can-i-display-extended-ascii-codes-characters-in-perl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!