Still umlauts

  • Thread starter Bertram Scharpf
  • Start date
B

Bertram Scharpf

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
 
J

Jason Foreman

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

That didn't work for me under Windows.

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

Jason
 
B

Bertram Scharpf

Hi,

Am Dienstag, 10. Mai 2005, 07:34:30 +0900 schrieb Jason Foreman:(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
 
J

Josef 'Jupp' SCHUGT

Hi!

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"

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).
 
B

Bertram Scharpf

Hi,

Am Freitag, 13. Mai 2005, 04:34:00 +0900 schrieb Josef 'Jupp' SCHUGT:
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.

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
 
J

Jonas Hartmann

Bertram said:
Hi,

Am Freitag, 13. Mai 2005, 04:34:00 +0900 schrieb Josef 'Jupp' SCHUGT:



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




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'.




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
 
B

Bertram Scharpf

Hi,

Am Freitag, 13. Mai 2005, 14:50:05 +0900 schrieb Jonas Hartmann:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top