[#35027] [Ruby 1.9-Bug#4352][Open] [patch] Fix eval(s, b) backtrace; make eval(s, b) consistent with eval(s) — "James M. Lawrence" <redmine@...>

Bug #4352: [patch] Fix eval(s, b) backtrace; make eval(s, b) consistent with eval(s)

16 messages 2011/02/01

[#35114] [Ruby 1.9-Bug#4373][Open] http.rb:677: [BUG] Segmentation fault — Christian Fazzini <redmine@...>

Bug #4373: http.rb:677: [BUG] Segmentation fault

59 messages 2011/02/06

[#35171] [Ruby 1.9-Bug#4386][Open] encoding: directive does not affect regex expressions — mathew murphy <redmine@...>

Bug #4386: encoding: directive does not affect regex expressions

9 messages 2011/02/09

[#35237] [Ruby 1.9-Bug#4400][Open] nested at_exit hooks run in strange order — Suraj Kurapati <redmine@...>

Bug #4400: nested at_exit hooks run in strange order

12 messages 2011/02/15

[ruby-core:35376] [Ruby 1.9 - Feature #4447] [Open] add String#byteslice() method

From: Suraj Kurapati <sunaku@...>
Date: 2011-02-25 08:49:12 UTC
List: ruby-core #35376
Issue #4447 has been reported by Suraj Kurapati.

----------------------------------------
Feature #4447: add String#byteslice() method
http://redmine.ruby-lang.org/issues/4447

Author: Suraj Kurapati
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 


Please add a String#byteslice() method to the Ruby 1.9 core API.

Without that method, I am forced to *inefficiently* perform byte-based
string slicing by (1) unpacking the entire string into an Array (with
String#unpack or worse: my_string.bytes.to_a) then (2) slicing that 
Array and finally (3) joining the sliced Array into a string (with 
Array#pack or worse: my_array.map(&:chr).join), all as shown below:

  class String
    unless method_defined? :byteslice
      ##
      # Does the same thing as String#slice but
      # operates on bytes instead of characters.
      #
      def byteslice(*args)
        unpack('C*').slice(*args).pack('C*')
      end
    end
  end

Thanks for your consideration.


-- 
http://redmine.ruby-lang.org

In This Thread

Prev Next