output becomes unicode

Discussion in 'Perl Misc' started by Leif Wessman, Sep 3, 2004.

  1. Leif Wessman

    Leif Wessman Guest

    Sorry for this silly question. I've seeked for answer but haven't found
    anything.

    This simple program:

    --
    #!/usr/bin/perl
    use strict;
    use warnings;
    print "åäö";
    --

    prints "åäö" (unicode characters)

    Is that a normal behaviour? I would like to see "åäö" instead. Is it
    possible to change?

    I'm using v5.8.0.

    Leif
     
    Leif Wessman, Sep 3, 2004
    #1
    1. Advertising

  2. Leif Wessman wrote:
    > Sorry for this silly question. I've seeked for answer but haven't
    > found anything.
    >
    > This simple program:
    >
    > --
    > #!/usr/bin/perl
    > use strict;
    > use warnings;
    > print "åäö";


    [Rest of posting being snipped as signature; don't do that]
    [Manually re-attached]

    > prints "åäö" (unicode characters)


    So? "åäö" are unicode characters, too. As are "abcdef...".
    Virtually all commonly used character sets are included in Unicode,
    therefore saying "x" is a Unicode character doesn't bear much information.

    > Is that a normal behaviour? I would like to see "åäö" instead. Is it
    > possible to change?


    It seems your Perl system (or the editor you are using to type and display
    your Perl program) and whatever you are using for display at runtime
    (xterm?) don't agree on the encoding. Did you try a simple "cat
    myperlprogram.pl"? You probably will see the same distortion.

    Just change your display devise to the same encoding as you are using to
    type your programs. How to do that, well, that depends on what you are using
    to display the execution results of your program.

    jue
     
    Jürgen Exner, Sep 3, 2004
    #2
    1. Advertising

  3. On Fri, 3 Sep 2004, Leif Wessman wrote:

    [...]
    > prints "åäö" (unicode characters)


    Well, your posting headers say:

    Content-Type: text/plain; charset="iso-8859-1"

    - so what you just posted was really a string of six iso-8859-1
    characters (not three "unicode" characters as you claimed).

    > Is that a normal behaviour? I would like to see "åäö" instead. Is it
    > possible to change?
    >
    > I'm using v5.8.0.


    My hunch is that you have a locale set which has utf-8 in it.

    What's the OS (redhat linux 9, for example?). Then this would be a
    known[1] problem. Either take the utf-8 out of the locale (for legacy
    behaviour), or upgrade to using utf-8 consistently (for the future).

    good luck

    [1] Hint: google for terms like > rh9 perl.5.8 utf-8 locale <
     
    Alan J. Flavell, Sep 3, 2004
    #3
  4. "Jürgen Exner" <> wrote:

    > Leif Wessman wrote:
    >
    > > Sorry for this silly question. I've seeked for answer but
    > > haven't found anything.
    > >
    > > This simple program:
    > >
    > > --
    > > #!/usr/bin/perl
    > > use strict;
    > > use warnings;
    > > print "åäö";

    >
    > [Rest of posting being snipped as signature; don't do that]
    > [Manually re-attached]


    Perhaps you should fix your newsreader so it doesn't consider "--"
    as a signature separator.

    Peter

    --
    #!/local/bin/perl5 -wp -*- mode: cperl; coding: iso-8859-1; -*-
    # matlab comment stripper (strips comments from Matlab m-files)
    s/^((?:(?:[])}\w.]'+|[^'%])+|'[^'\n]*(?:''[^'\n]*)*')*).*/$1/x;
     
    Peter J. Acklam, Sep 3, 2004
    #4
    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. Nick
    Replies:
    0
    Views:
    616
  2. TN Bella
    Replies:
    1
    Views:
    1,550
    TN Bella
    Jul 1, 2004
  3. davidw
    Replies:
    3
    Views:
    441
    Curt_C [MVP]
    Aug 27, 2004
  4. Replies:
    9
    Views:
    1,046
    Juha Nieminen
    Aug 22, 2007
  5. Stef Mientki

    and becomes or and or becomes and

    Stef Mientki, May 22, 2011, in forum: Python
    Replies:
    9
    Views:
    336
    Chris Angelico
    May 28, 2011
Loading...

Share This Page