<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>yuimat</author_name>
  <author_url>https://blog.hatena.ne.jp/yuimat/</author_url>
  <blog_title>Scala日記</blog_title>
  <blog_url>https://ym.hatenadiary.jp/</blog_url>
  <categories>
    <anon>Scala</anon>
  </categories>
  <description>ScalaやJavaは拡張領域の文字をサロゲートペアで表すので、文字数をカウントしたいときに単純に文字列のサイズを取ると実際の文字数とずれてしまう。Java 1.5からはUnicodeのコードポイント を数えるメソッドが追加されているので、これを使えば正確に文字数をカウントできる。 以下、地球の絵文字を例に取って説明。 scala&gt; val earth = &quot;\uD83C\uDF0D&quot; earth: String = 🌍 scala&gt; println(earth, earth.length) (🌍,2) scala&gt; earth.codePointCount(0, earth.length) …</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fym.hatenadiary.jp%2Fentry%2F2015%2F07%2F08%2F175023&quot; title=&quot;Unicodeの拡張領域の文字を一文字とカウントする - Scala日記&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>2015-07-08 17:50:23</published>
  <title>Unicodeの拡張領域の文字を一文字とカウントする</title>
  <type>rich</type>
  <url>https://ym.hatenadiary.jp/entry/2015/07/08/175023</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
