[MacRuby-devel] String#sub/gsub and text encodings

Vincent Isambart vincent.isambart at gmail.com
Fri May 20 19:10:34 PDT 2011


Hi,

> I finally found time to further investigate this.
Thanks for investigating it.

> Am I doing something wrong?  If not, I'll file a ticket.
No it's indeed a bug, could you please file a ticket.
By the way I've made a shorter version of your code:
-------
framework 'Cocoa'

s1 = NSMutableString.stringWithString("this is a test script.")
s1.sub!(/test/, "$B$"(B")
puts s1 #=> this is a $B!1(IAB(B script.

s2 = NSMutableString.stringWithString("this is a test script.")
s2[10..14] = "$B$"(B"
puts s2 #=> this is a $B!1(IAB(B script.
-------
(in fact sub! uses []= internally)

Cheers,
Vincent


More information about the MacRuby-devel mailing list