From: shugo@... Date: 2017-03-13T15:05:40+00:00 Subject: [ruby-core:80137] [Ruby trunk Feature#13110] Byte-based operations for String Issue #13110 has been updated by shugo (Shugo Maeda). shyouhei (Shyouhei Urabe) wrote: > We looked at this issue at today's developer meeting. > > I remember no one there had strong pro- or contra against byteoffset and byteindex. But what about bytesplice? Seems a programmer can pass arbitrary byte index to it. That can be troublesome because the passed index might be a middle of some code point. It's relatively easy to implement bytesplice using force_encoding at my own risk, so I withdraw the proposal to introduce bytesplice. ---------------------------------------- Feature #13110: Byte-based operations for String https://bugs.ruby-lang.org/issues/13110#change-63565 * Author: shugo (Shugo Maeda) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- How about to add byte-based operations for String? ```ruby s = "���������������������������" p s.byteindex(/������/, 4) #=> 18 x, y = Regexp.last_match.byteoffset(0) #=> [18, 24] s.bytesplice(x...y, "���������") p s #=> "������������������������������" ``` ---Files-------------------------------- byteindex.diff (2.83 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: