perl print ASCII

Discussion in 'Perl Misc' started by mud_saisem, Oct 2, 2009.

  1. mud_saisem

    mud_saisem Guest

    Hi All,

    Can anybody tell me how to print ASCII characters in perl ?

    eg: I would like to print the following ASCII character in perl using
    the following Alt 63214, which gives you ¯

    So at the end of the day i would like perl to print the following



    This is my perl line, with a underline !
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
    mud_saisem, Oct 2, 2009
    #1
    1. Advertising

  2. mud_saisem <> wrote:
    >Can anybody tell me how to print ASCII characters in perl ?


    For printable ASCII characters you just print them like in

    print "This is an unsorted list of some ASCII characters";

    >eg: I would like to print the following ASCII character in perl using
    >the following Alt 63214, which gives you ¯


    That is not one of the 95 printable ASCII character (and neither one of
    control characters), see
    http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters

    jue
    Jürgen Exner, Oct 2, 2009
    #2
    1. Advertising

  3. mud_saisem

    mud_saisem Guest

    On Oct 2, 9:40 am, Jürgen Exner <> wrote:
    > mud_saisem <> wrote:
    > >Can anybody tell me how to print ASCII characters in perl ?

    >
    > For printable ASCII characters you just print them like in
    >
    >         print "This is an unsorted list of some ASCII characters";
    >
    > >eg: I would like to print the following ASCII character in perl using
    > >the following Alt 63214, which gives you ¯

    >
    > That is not one of the 95 printable ASCII character (and neither one of
    > control characters), seehttp://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters
    >
    > jue


    Thanks for the response Jue, I understand that my use of the words
    "ASCII characters" was not entirely correct, but I was not sure how
    else to describe what I was after.

    What I am after is a way to print ¯ character in perl and i am not
    sure how to do it.
    mud_saisem, Oct 2, 2009
    #3
  4. mud_saisem

    Guest

    On Thu, 1 Oct 2009 16:01:20 -0700 (PDT), mud_saisem <> wrote:

    >Hi All,
    >
    >Can anybody tell me how to print ASCII characters in perl ?
    >
    >eg: I would like to print the following ASCII character in perl using
    >the following Alt 63214, which gives you ¯
    >
    >So at the end of the day i would like perl to print the following
    >
    >
    >
    >This is my perl line, with a underline !


    (now the underline is under some different line)
    >¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯


    Unicode combining diacritics.
    http://www.answers.com/topic/combining-character

    In digital typography, combining characters are characters that are intended
    to modify other characters. The most common combining characters in the
    Latin script are the combining diacritical marks (including combining accents).

    Unicode also contains many precomposed characters, so that in many cases
    it is possible to use both combining diacritics and precomposed characters,
    at the user's or application's choice. This leads to a requirement to perform
    Unicode normalization before comparing two Unicode strings and to carefully
    design encoding converters to correctly map all of the valid ways to represent
    a character in Unicode to a legacy encoding to avoid data loss.[1]

    In Unicode, the main block of combining diacritics for European languages and the
    International Phonetic Alphabet is U+0300–U+036F.
    Combining diacritical marks are also present in many other blocks of
    Unicode characters. In Unicode, diacritics are always added after the
    main character. It is thus possible to add several diacritics to the same
    character, although as of 2006, few applications support correct rendering of
    such combinations ....

    ________________________________
    For your reading enjoyment.
    -sln
    , Oct 2, 2009
    #4
  5. mud_saisem <> wrote:
    >What I am after is a way to print character in perl and i am not
    >sure how to do it.


    I still don't understand where you got a problem. A simple
    print '¯';
    will print the overscore character just fine.

    Maybe you got a cross-code page problem? Your Perl program written in
    one code page but your program run in a different code page? Like your
    program written in Notepad (e.g Windows-1252 or UTF-8) but run in a DOS
    command prompt (e.g. DOS CP437 or CP850)?

    jue
    Jürgen Exner, Oct 2, 2009
    #5
  6. mud_saisem wrote:
    > On Oct 2, 9:40 am, Jürgen Exner <> wrote:
    >> mud_saisem <> wrote:
    >>> Can anybody tell me how to print ASCII characters in perl ?

    >> For printable ASCII characters you just print them like in
    >>
    >> print "This is an unsorted list of some ASCII characters";
    >>
    >>> eg: I would like to print the following ASCII character in perl using
    >>> the following Alt 63214, which gives you ¯

    >> That is not one of the 95 printable ASCII character (and neither one of
    >> control characters), seehttp://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters
    >>
    >> jue

    >
    > Thanks for the response Jue, I understand that my use of the words
    > "ASCII characters" was not entirely correct,


    your use of "ASCII characters" was, unfortunately, entirely incorrect.

    > but I was not sure how
    > else to describe what I was after.


    The character you want is a character in the Latin-1 (ISO 8859-1)
    encoding. It's code point is 0xAF. It's name is Macron. I believe it is
    intended to be used in composing certain long vowels in some languages
    or in transliterations of some other languages.

    >
    > What I am after is a way to print ¯ character in perl and i am not
    > sure how to do it.


    You need to be clear about the encoding of the text file containing your
    Perl program and the encoding in use by the display device. If both are
    using ISO 8859-1 (or similar) you should be able to "print '¯';"

    C:\>chcp 1252
    Active code page: 1252

    C:\>perl -e "print qq(XX\n¯\xAF)"
    XX
    ¯¯

    --
    RGB
    RedGrittyBrick, Oct 2, 2009
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. TOXiC
    Replies:
    5
    Views:
    1,255
    TOXiC
    Jan 31, 2007
  2. keto
    Replies:
    0
    Views:
    936
  3. David Cournapeau

    print a vs print '%s' % a vs print '%f' a

    David Cournapeau, Dec 30, 2008, in forum: Python
    Replies:
    0
    Views:
    348
    David Cournapeau
    Dec 30, 2008
  4. James O'Brien
    Replies:
    3
    Views:
    252
    Ben Morrow
    Mar 5, 2004
  5. Alextophi
    Replies:
    8
    Views:
    512
    Alan J. Flavell
    Dec 30, 2005
Loading...

Share This Page