Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #2405
| From | Angelo NN <storm8000@gmail.com> |
|---|---|
| Newsgroups | comp.lang.ruby |
| Subject | Re: Windows 2008 Server: Reading Text File with Ruby. |
| Date | 2011-04-06 15:15 -0500 |
| Organization | Service de news de lacave.net |
| Message-ID | <9b8c0e6b9f2e51dc8cfa342151809bf7@ruby-forum.com> (permalink) |
| References | (1 earlier) <6e73.4d9cc013.54317@roo.daria.co.uk> <4b3f3961a9695772bb455a21644e06e5@ruby-forum.com> <7071.4d9cc332.7496@roo.daria.co.uk> <4f8ab5a3afd40a28a18dca455849ed3d@ruby-forum.com> <7447.4d9cc91f.1d15c@roo.daria.co.uk> |
Jonathan Hudson wrote in post #991297:
> On Thu, 7 Apr 2011 04:58:54 +0900, Angelo NN wrote:
>
>> > or perhaps
>>
>> >> contents = File.open('tmp', 'r:utf-16') { |f| f.read }
>> (irb):15: warning: Unsupported encoding utf-16 ignored
>> =>
>> "\xFF\xFE\n\x00\n\x00\n\x00\n\x00C\x00a\x00p\x00a\x00c\x00i\x00t\x00y\x00=\x0
>>
08\x005\x008\x009\x009\x003\x004\x005\x009\x002\x00\n\x00\n\x00\n\x00\n\x00\n\x0
>> 0\n\x00"
>>
>
> I think the old ways still work:
>
> require 'iconv'
> content=File.binread('tmp')
> # TO FROM (set TO to 'native encoding')
> text = Iconv::conv("utf-8",'utf-16', content)
> puts text
>
> -jh
Wow - Awesome.
That worked.
Thanks Jonathan!
--
Posted via http://www.ruby-forum.com/.
Back to comp.lang.ruby | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Windows 2008 Server: Reading Text File with Ruby. Angelo NN <storm8000@gmail.com> - 2011-04-06 14:30 -0500
Re: Windows 2008 Server: Reading Text File with Ruby. Jonathan Hudson <jh_ruby-lang@daria.co.uk> - 2011-04-06 14:33 -0500
Re: Windows 2008 Server: Reading Text File with Ruby. Angelo NN <storm8000@gmail.com> - 2011-04-06 14:35 -0500
Re: Windows 2008 Server: Reading Text File with Ruby. Jonathan Hudson <jh_ruby-lang@daria.co.uk> - 2011-04-06 14:47 -0500
Re: Windows 2008 Server: Reading Text File with Ruby. Angelo NN <storm8000@gmail.com> - 2011-04-06 14:58 -0500
Re: Windows 2008 Server: Reading Text File with Ruby. Jonathan Hudson <jh_ruby-lang@daria.co.uk> - 2011-04-06 15:12 -0500
Re: Windows 2008 Server: Reading Text File with Ruby. Angelo NN <storm8000@gmail.com> - 2011-04-06 15:15 -0500
Re: Windows 2008 Server: Reading Text File with Ruby. "F. Senault" <fred@lacave.net> - 2011-04-06 22:45 +0200
csiph-web