Still umlauts

Discussion in 'Ruby' started by Bertram Scharpf, May 9, 2005.

  1. Hi,

    does this no longer work?

    --------------------
    #!/usr/bin/env ruby
    # -*- coding: UTF-8 -*-

    puts $KCODE
    puts "äöüÄÖÜß"
    --------------------

    I tried it with Ruby 1.8.2 and 1.9, Debian Linux.
    What do I miss?

    Bertram


    --
    Bertram Scharpf
    Stuttgart, Deutschland/Germany
    http://www.bertram-scharpf.de
    Bertram Scharpf, May 9, 2005
    #1
    1. Advertising

  2. On 5/9/05, Bertram Scharpf <> wrote:
    > Hi,
    >
    > does this no longer work?
    >
    > --------------------
    > #!/usr/bin/env ruby
    > # -*- coding: UTF-8 -*-
    >
    > puts $KCODE
    > puts "äöüÄÖÜß"
    > --------------------
    >
    > I tried it with Ruby 1.8.2 and 1.9, Debian Linux.
    > What do I miss?
    >
    > Bertram
    >
    > --
    > Bertram Scharpf
    > Stuttgart, Deutschland/Germany
    > http://www.bertram-scharpf.de
    >
    >


    That didn't work for me under Windows.

    Can you add -Ku to the shebang line? That did work for me.

    Jason
    Jason Foreman, May 9, 2005
    #2
    1. Advertising

  3. Hi,

    Am Dienstag, 10. Mai 2005, 07:34:30 +0900 schrieb Jason Foreman:
    > On 5/9/05, Bertram Scharpf <> wrote:
    > > does this no longer work?
    > >
    > > --------------------
    > > #!/usr/bin/env ruby
    > > # -*- coding: UTF-8 -*-
    > >
    > > puts $KCODE
    > > puts "äöüÄÖÜß"
    > > --------------------
    > >
    > > I tried it with Ruby 1.8.2 and 1.9, Debian Linux.
    > > What do I miss?

    (Outputs "None" and "äöüÄÖÜß".)
    >
    > That didn't work for me under Windows.
    >
    > Can you add -Ku to the shebang line? That did work for me.


    That's exactly the problem. Only the first of these both works:

    #!/usr/local/bin/ruby -Ku
    #!/usr/bin/env ruby -Ku

    So, I came to
    <http://www.ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-core/4192>.
    But it doesn't seem to work here and I cannot find anything
    in the source code.

    Bertram


    --
    Bertram Scharpf
    Stuttgart, Deutschland/Germany
    http://www.bertram-scharpf.de
    Bertram Scharpf, May 10, 2005
    #3
  4. Hi!

    At Tue, 10 May 2005 06:58:30 +0900, Bertram Scharpf wrote:
    > does this no longer work?


    You forgot to define the meaning of 'no longer works':

    - What precisely do you mean by 'it works'?

    - What is the reference to compare to?

    - Did you switch to a different terminal emulation or change your
    terminal emulation's settings since 'it works'?

    > --------------------
    > #!/usr/bin/env ruby
    > # -*- coding: UTF-8 -*-
    >=20
    > puts $KCODE
    > puts "=E4=F6=FC=C4=D6=DC=DF"
    > --------------------
    >=20
    > I tried it with Ruby 1.8.2 and 1.9, Debian Linux.
    > What do I miss?


    I wrote the scriptlet to deppian.rb; ruby deppian.rb results in:

    NONE
    =E4=F6=FC=C4=D6=DC=DF

    NONE
    =C3=A4=C3=B6=C3=BC=C3=C3=C3=C3

    or even more alien results. The former is for a utf-8 terminal, the
    latter for an iso-8859-1 terminal.

    When in doubt *set* $KCODE explicitly.

    Note that the above quote has been converted from utf-8 to iso-8859-1
    to avoid artefacts resulting from mixed use of iso-10646 and iso-8859
    - fortunately 'wanderlust' does not choose the charset without askign
    the user to accept the choice.

    Josef 'Jupp' SCHUGT
    --=20
    Zehn von zehn Unix-Nutzern best=E4tigen... *r=F6chel*... Neun von neun
    Unix-Benutzern best=E4tigen: Unix *ist* benutzerfreundlich (in Anlehnung
    an einen Werbespot f=FCr Fisherman's Friend).
    Josef 'Jupp' SCHUGT, May 12, 2005
    #4
  5. Hi,

    Am Freitag, 13. Mai 2005, 04:34:00 +0900 schrieb Josef 'Jupp' SCHUGT:
    > At Tue, 10 May 2005 06:58:30 +0900, Bertram Scharpf wrote:
    > > does this no longer work?

    >
    > You forgot to define the meaning of 'no longer works':
    >
    > - What precisely do you mean by 'it works'?


    Sorry, that was not actually elaborate. Now I think it
    never worked at all.

    > > --------------------
    > > #!/usr/bin/env ruby
    > > # -*- coding: UTF-8 -*-
    > >
    > > puts $KCODE
    > > puts "äöüÄÖÜß"
    > > --------------------
    > >
    > > I tried it with Ruby 1.8.2 and 1.9, Debian Linux.
    > > What do I miss?


    In the meantime I received an answer in ruby-core and it
    seems Matz just _planned_ to implement it but didn't have
    the time yet.

    The problem arises when my program is run on SuSE Linux
    where the default encoding is UTF-8.

    A better way to test in which encoding you reside is:

    "ä" =~ /./
    puts $&.length

    This gives 1 in `None' and 2 in `UTF-8'.

    > When in doubt *set* $KCODE explicitly.


    This has no influence on how the source code is read. The
    string "Ã" produces an error when `ruby -Ku' is called.

    Of course I should have written "\xc3\xa4" and "\xc3".

    Sorry again for the noise.

    Bertram


    --
    Bertram Scharpf
    Stuttgart, Deutschland/Germany
    http://www.bertram-scharpf.de
    Bertram Scharpf, May 13, 2005
    #5
  6. Bertram Scharpf wrote:
    > Hi,
    >
    > Am Freitag, 13. Mai 2005, 04:34:00 +0900 schrieb Josef 'Jupp' SCHUGT:
    >
    >>At Tue, 10 May 2005 06:58:30 +0900, Bertram Scharpf wrote:
    >>
    >>>does this no longer work?

    >>
    >>You forgot to define the meaning of 'no longer works':
    >>
    >> - What precisely do you mean by 'it works'?

    >
    >
    > Sorry, that was not actually elaborate. Now I think it
    > never worked at all.
    >
    >
    >>>--------------------
    >>>#!/usr/bin/env ruby
    >>># -*- coding: UTF-8 -*-
    >>>
    >>>puts $KCODE
    >>>puts "äöüÄÖÜß"
    >>>--------------------
    >>>
    >>>I tried it with Ruby 1.8.2 and 1.9, Debian Linux.
    >>>What do I miss?

    >
    >
    > In the meantime I received an answer in ruby-core and it
    > seems Matz just _planned_ to implement it but didn't have
    > the time yet.
    >
    > The problem arises when my program is run on SuSE Linux
    > where the default encoding is UTF-8.
    >
    > A better way to test in which encoding you reside is:
    >
    > "ä" =~ /./
    > puts $&.length
    >
    > This gives 1 in `None' and 2 in `UTF-8'.
    >
    >
    >>When in doubt *set* $KCODE explicitly.

    >
    >
    > This has no influence on how the source code is read. The
    > string "Ã" produces an error when `ruby -Ku' is called.
    >
    > Of course I should have written "\xc3\xa4" and "\xc3".


    Is this the only way to handle strings UTF-8 in ruby?

    >
    > Sorry again for the noise.
    >
    > Bertram
    >
    >


    regards
    jonas
    Jonas Hartmann, May 13, 2005
    #6
  7. Hi,

    Am Freitag, 13. Mai 2005, 14:50:05 +0900 schrieb Jonas Hartmann:
    > Bertram Scharpf wrote:
    > >Of course I should have written "\xc3\xa4" and "\xc3".

    >
    > Is this the only way to handle strings UTF-8 in ruby?


    You never know what happens to your mail in a thousand
    different user agents.

    Bertram


    --
    Bertram Scharpf
    Stuttgart, Deutschland/Germany
    http://www.bertram-scharpf.de
    Bertram Scharpf, May 13, 2005
    #7
    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. Axel Dahmen
    Replies:
    3
    Views:
    4,410
    Axel Dahmen
    Apr 30, 2005
  2. John Dalberg
    Replies:
    1
    Views:
    1,852
    Joerg Jooss
    Feb 17, 2006
  3. Replies:
    10
    Views:
    1,006
    Shmuel (Seymour J.) Metz
    Nov 1, 2005
  4. Moritz Beller

    Where have all the umlauts gone?

    Moritz Beller, Nov 7, 2004, in forum: C++
    Replies:
    1
    Views:
    322
    Victor Bazarov
    Nov 7, 2004
  5. Joerg Lehmann

    Print formatted Strings with Umlauts

    Joerg Lehmann, Feb 11, 2004, in forum: Python
    Replies:
    4
    Views:
    368
    Joerg Lehmann
    Feb 12, 2004
Loading...

Share This Page