<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>mtoyoshi</author_name>
  <author_url>https://blog.hatena.ne.jp/mtoyoshi/</author_url>
  <blog_title>mtoyoshi開発メモ</blog_title>
  <blog_url>https://mtoyoshi.hateblo.jp/</blog_url>
  <categories>
    <anon>ruby</anon>
  </categories>
  <description>文字コードを勉強するにあたって、バイト表現が簡単に分かった方が便利だったので。 もう何度も同じようなのを作っているんだけど、改めて。 def print(str, cs) str.encode(cs).each_char do |c| puts &quot;#{c} : #{c.bytes.map{|b| b.to_s(16).upcase}.join(' ')}&quot; end end こんなふうに使うと、、 print(&quot;あｱA&quot;, &quot;Shift_JIS&quot;) こんな表示になります。 あ : 82 A0 ｱ : B1 A : 41 そうそう、rubyはサロゲートペア文字もなんのその。ちゃんと文字の長さは1文…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fmtoyoshi.hateblo.jp%2Fentry%2F20100413%2F1271167307&quot; title=&quot;文字のバイト列の表示 - mtoyoshi開発メモ&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>2010-04-13 23:01:47</published>
  <title>文字のバイト列の表示</title>
  <type>rich</type>
  <url>https://mtoyoshi.hateblo.jp/entry/20100413/1271167307</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
