--mimepart_4cf816967cb4c_5e62b8cae281142
Content-Type: text/plain
Content-Transfer-Encoding: Quoted-printable
Content-Disposition: inline

Bug #4112: StringIO#gets(limit) returns incomplete string
http://redmine.ruby-lang.org/issues/show/4112

莎欠エ Nobuyoshi Nakada
ステータス: Assigned, 優先度: Normal
担当者: Nobuyoshi Nakada, カテゴリ: ext
ruby -v: 1.9.3 r30061

StringIO#getsに長さを指定したとき、マルチバイト文字が途中で切れることがあります。

  StringIO.new("\u3042").gets(1) #=> "\xE3"
  StringIO.new("a".encode("utf-16be")).gets(1) #=> "\x00"


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

--mimepart_4cf816967cb4c_5e62b8cae281142
Content-Type: application/octet-stream; name=stringio_gets.diff
Content-Transfer-Encoding: Base64
Content-Disposition: attachment; filename=stringio_gets.diff

ZGlmZiAtLWdpdCBpL2V4dC9zdHJpbmdpby9zdHJpbmdpby5jIHcvZXh0L3N0
cmluZ2lvL3N0cmluZ2lvLmMKaW5kZXggNzVmOGNkNy4uN2VkZjcxMSAxMDA2
NDQKLS0tIGkvZXh0L3N0cmluZ2lvL3N0cmluZ2lvLmMKKysrIHcvZXh0L3N0
cmluZ2lvL3N0cmluZ2lvLmMKQEAgLTk1NCw3ICs5NTQsNyBAQCBzdHJpb19n
ZXRsaW5lKGludCBhcmdjLCBWQUxVRSAqYXJndiwgc3RydWN0IFN0cmluZ0lP
ICpwdHIpCiAgICAgZSA9IHMgKyBSU1RSSU5HX0xFTihwdHItPnN0cmluZyk7
CiAgICAgcyArPSBwdHItPnBvczsKICAgICBpZiAobGltaXQgPiAwICYmIHMg
KyBsaW1pdCA8IGUpIHsKLQllID0gcyArIGxpbWl0OworCWUgPSByYl9lbmNf
cmlnaHRfY2hhcl9oZWFkKHMsIHMgKyBsaW1pdCwgZSwgcmJfZW5jX2dldChw
dHItPnN0cmluZykpOwogICAgIH0KICAgICBpZiAoTklMX1Aoc3RyKSkgewog
CXN0ciA9IHN0cmlvX3N1YnN0cihwdHIsIHB0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