From: Elliott Cable Date: 2009-07-22T06:50:14+09:00 Subject: Re: Byte–stream parsing in Ruby Brian Candler wrote: > Elliott Cable wrote: >> The goal is to devise some method by which I can: >> >> 1) Determine whether or not an `Array` of so–far–received bytes is, yet, >> a valid `String` of a given `Encoding` > >>> "über".bytes.to_a > => [195, 188, 98, 101, 114] >>> a = "\xc3".force_encoding("UTF-8") > => "\xC3" >>> a.valid_encoding? > => false >>> a << "\xbc" > => "ü" >>> a.valid_encoding? > => true >>> Hrm, #valid_encoding? is very helpful. But how can I stuff numerical (`Fixnum`) bytes onto the string? -- Posted via http://www.ruby-forum.com/.