Hello,

I'm developing a little game intended to be run into a console. For this reason I have to be sure about which characters can I print into the console.

1) Can I assume chars 0..127 are the same everywhere? I fear not.. at least some difference between Linux and Windows

perl -e "print chr($_) for 0..127" # cmd.exe  123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcde +fghijklmnopqrstuvwxyz{|}~ perl -e 'print chr($_) for 0..127' # linux 123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuv +wxyz{|}~ # update: I forgot the tilde in the linux output thanks choroba who sp +otted it

On some windows version first chars ( control ones 0..31 ) are displayed as funny elements: smiling faces, palying card seeds.. I suppose this is not portable at all.

2) What about extended ASCII?

perl -e "print chr($_) for 128..255" # cmd.exe perl -e 'print chr($_) for 128..255' # linux
I see a lot fancy charcaters printed in cmd.exe and only garbage in Linux console. Here the differences are bigger.. I suspect I cannot trust these chars to be the same everywhere.

3) cmd.exe has the codepage notion (see chcp where is stated the very limited support for unicode). Linux has the locale with the character set is specified.

4) So which characters I can expect to be printed equal on different platform? Only 32..127 ? what about 128..255 ones?

5) M for mountains and m for hills are a bit ugly to see, so I played a bit with bitfontmaker2 website and it permit the easy creation of a custom font. It offers to modify/create 316 (?!) different chars... how can these are mapped with our perl 0..255 ones? I know that cmd.exe only has a, even limeted, support for monospaced ttf fonts: I have tried a custom Lucida Console font with success ( horrible atm available here ). Are these fonts copyrighted? In case I can create a custom, usable font, how can I map to these custom chars? via chr(xx) ?

Thanks for any clarification you will be able to provide.

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

In reply to [OT] ASCII, cmd.exe, linux console, charset, code pages, fonts and other amenities by Discipulus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.