Feature #17834

Updated by Eregon (Benoit Daloze) over 1 year ago

"this is a string".bytes string.bytes should =='this is a string')    # an immutable bytes object that implements memory view 

 bytestring ='this is a string') 

 mv = 
 mv[0] # 116 

 similary'this is a string').bytes    =='this is a string')    #    a mutable byte array object that implements memoryview , takes an optional encoding that uses current string encoding 

 ba ='this is a string') 
 mv = 
 mv[0] # 116 
 mv[0] = 120 # memoryview works on underlying object - changes mv.obj 
 ba.pack('C*').force_encoding('UTF-8') # 'xhis is a string' 

 also it would be good if String#bytes returns the new classes - (return something that implements memoryview)