<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>bamch0h</author_name>
  <author_url>https://blog.hatena.ne.jp/bamch0h/</author_url>
  <blog_title>bamchoh’s diary</blog_title>
  <blog_url>https://bamch0h.hatenablog.com/</blog_url>
  <categories>
    <anon>Ruby</anon>
  </categories>
  <description>はじまり Rubyに限った話ではないのかもしれないですが、Rubyで改行を含むテキストデータを送受信するようなプログラムをWindowsで書いていた時に思った通りに処理されなくて嵌ってしまったので、自戒を込めてブログに残しておきます。 結論 Windowsで CR/LF をそのまま受け渡したいのであれば、IO#binmodeを設定しよう!! 詳細 例えば以下のようなプログラムがあったとします。 write.rb $stdout.write &quot;1\r2\n3\r\n&quot; $stdout.flush read.rb while char = $stdin.getc p char end 以下のように…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fbamch0h.hatenablog.com%2Fentry%2F2021%2F08%2F23%2F015422&quot; title=&quot; Ruby(Windows)で改行付き文字列データを扱う場合はテキストモード(バイナリモード)に気をつけろ!! - bamchoh’s diary&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2021-08-23 01:54:22</published>
  <title> Ruby(Windows)で改行付き文字列データを扱う場合はテキストモード(バイナリモード)に気をつけろ!!</title>
  <type>rich</type>
  <url>https://bamch0h.hatenablog.com/entry/2021/08/23/015422</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
