Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Re: ruby 1.9.1: Encoding trouble: broken US-ASCII String
Yukihiro Matsumoto
12/15/2008 5:32:00 PM
Hi,
In message "Re: ruby 1.9.1: Encoding trouble: broken US-ASCII String"
on Tue, 16 Dec 2008 01:16:55 +0900, Brian Candler <b.candler@pobox.com> writes:
|It seems to go against DRY to have to write "r:binary" or "rb:binary"
|when opening lots of binary files. But if I remember to use
|#!/usr/bin/ruby -Knw everywhere that should be OK.
|
|However, I also don't like the unstated assumption that all Strings
|contain text.
open(path, "rb") is your friend. It sets encoding to binary.
|In RFC2045 (MIME), there is a distinction made between 7bit text, 8bit
|text, and binary data.
|
|But if you label a string as "binary", Ruby changes this to
|"ASCII-8BIT". I think that is a misrepresentation of that data, if it is
|not actually ASCII-based text. I would much rather it made no assertion
|about the content than a wrong assertion.
|--
|Posted via
http://www.ruby-...
.
|
1 Answer
Brian Candler
12/15/2008 8:45:00 PM
0
Yukihiro Matsumoto wrote:
> open(path, "rb") is your friend. It sets encoding to binary.
Thanks.
"rb" is now performing two jobs then - prevent line-ending translation
(on those platforms which do it), and set encoding to binary. Something
to remember.
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: ruby 1.9.1: Encoding trouble: broken US-ASCII String
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password