🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: pl.comp.lang.ruby
2 messages
2 total messages Started by moldovenu Wed, 07 Nov 2007 11:45
unicode
#704
Author: moldovenu
Date: Wed, 07 Nov 2007 11:45
14 lines
931 bytes
jak wygląda obecnie obsługa unikodu w Rubym?
jest jakaś opcja, pragma, biblioteka czy to dopiero w rb2?

str = "gżegżółka"
=> "g\305\274eg\305\274\303\263\305\202ka"

str[1].to_i.chr
=> "\305"

fuj!

;)

adam
Re: unicode
#705
Author: TomekC
Date: Wed, 07 Nov 2007 12:30
30 lines
1427 bytes
moldovenu pisze:
> jak wygląda obecnie obsługa unikodu w Rubym?
> jest jakaś opcja, pragma, biblioteka czy to dopiero w rb2?
> 
> str = "gżegżółka"
> => "g\305\274eg\305\274\303\263\305\202ka"
> 
> str[1].to_i.chr
> => "\305"
> 
> fuj!

Niestety, z tego co wiem, to na razie trzeba się posługiwać atrapą, 
czyli metodą "chars"

str = "gżegżółka"

str.chars.length
=> 9

do str.chars aplikują się wszystkie metody klasy string:

str.chars.upcase
=> "GŻEGŻÓŁKA"

itd...


-- 
Tomek małpka japko kropka info.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads