[macruby-changes] [4484] MacRuby/trunk/lib/stringio.rb
source_changes at macosforge.org
source_changes at macosforge.org
Tue Aug 31 15:54:58 PDT 2010
Revision: 4484
http://trac.macosforge.org/projects/ruby/changeset/4484
Author: lsansonetti at apple.com
Date: 2010-08-31 15:54:57 -0700 (Tue, 31 Aug 2010)
Log Message:
-----------
StringIO#write: take care of encodings
Modified Paths:
--------------
MacRuby/trunk/lib/stringio.rb
Modified: MacRuby/trunk/lib/stringio.rb
===================================================================
--- MacRuby/trunk/lib/stringio.rb 2010-08-31 08:47:59 UTC (rev 4483)
+++ MacRuby/trunk/lib/stringio.rb 2010-08-31 22:54:57 UTC (rev 4484)
@@ -102,7 +102,7 @@
self
end
-
+
# strio.string = string -> string
#
# Changes underlying String object, the subject of IO.
@@ -492,6 +492,10 @@
if @append || (pos >= string.length)
# add padding in case it's needed
str = str.rjust((pos + str.length) - string.length, "\000") if (pos > string.length)
+ enc1, enc2 = str.encoding, @string.encoding
+ if enc1 != enc2
+ str = str.dup.force_encoding(enc2)
+ end
@string << str
@pos = string.length
else
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100831/aa38f816/attachment.html>
More information about the macruby-changes
mailing list