Hello

I wonder if it is possible to enforce encoding of string in ruby 1.9.
Let say I have following example:

C:\enc>echo p 'test'.encoding > encoding.rb
C:\enc>ruby encoding.rb
#<Encoding:US-ASCII>

Thats fine. But what if I like to have in single file ASCII, UTF-8 or
strings with other encodings, i.e.

C:\enc>echo p 'zufテ、llige_ナセluナ・ouト耕テス'.encoding > encoding.rb
C:\enc>ruby encoding.rb
encoding.rb:1: invalid multibyte char (US-ASCII)

I know that for this particular case I could use directive on top of the
file, but I would like to see something in following manner:

String.new 'zufテ、llige_ナセluナ・ouト耕テス', Encoding.CP852

It means read the content in between quotes binary and interpret it
according to specified encoding.

Vit
-- 
Posted via http://www.ruby-forum.com/.