[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Still umlauts

Bertram Scharpf

5/9/2005 9:59:00 PM

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


7 Answers

threeve.org

5/9/2005 10:35:00 PM

0

On 5/9/05, Bertram Scharpf <lists@bertram-scharpf.de> 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-...
>
>

That didn't work for me under Windows.

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

Jason



Bertram Scharpf

5/10/2005 5:24:00 AM

0

Hi,

Am Dienstag, 10. Mai 2005, 07:34:30 +0900 schrieb Jason Foreman:
> On 5/9/05, Bertram Scharpf <lists@bertram-scharpf.de> 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-cor....
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-...


Josef 'Jupp' Schugt

5/12/2005 7:34:00 PM

0

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 -*-
>
> puts $KCODE
> puts "äöüÄÖÜß"
> --------------------
>
> 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
äöüÄÖÜß

NONE
äöüÃÃÃÃ

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
--
Zehn von zehn Unix-Nutzern bestätigen... *röchel*... Neun von neun
Unix-Benutzern bestätigen: Unix *ist* benutzerfreundlich (in Anlehnung
an einen Werbespot für Fisherman's Friend).


Bertram Scharpf

5/13/2005 4:04:00 AM

0

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


Jonas Hartmann

5/13/2005 5:50:00 AM

0

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


Brian Schröder

5/13/2005 10:16:00 AM

0

On 13/05/05, Jonas Hartmann <Mail@jonas-hartmann.com> wrote:> 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> > No, it is perfectly possible to use utf-8 encoded source-files. (Butyou should use ruby -Ku then).But some UTF-8 things are a bit weird. E.g. the length of an UTF-8String is the length of its bytes not the number of characters, so Ihad to write my own utf-8_length routine.regards,Brian-- http://ruby.brian-schroeder.d... instrument chords: http://chordlist.brian-sch...

Bertram Scharpf

5/13/2005 9:59:00 PM

0

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