<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>S_a_k_U</author_name>
  <author_url>https://blog.hatena.ne.jp/S_a_k_U/</author_url>
  <blog_title>S_a_k_Uの日記みたいなDB</blog_title>
  <blog_url>https://saku-jp.hatenablog.com/</blog_url>
  <categories>
    <anon>技術メモ</anon>
    <anon>Java</anon>
  </categories>
  <description>Javaで表示文字数により文字列操作する時、昔はShift JIS？MS932？Windows-31J？でごにょごにょ処理してた記憶が。 Unicodeでいろいろ見てると、半角文字(表示幅1桁)と半角以外の文字(表示幅2桁)で判定すればよさげ。 但し、サロゲートペアを意識した瞬間ちょっと処理が面倒になるみたい。 以下の処理もサロゲートペアが含まれているかどうかで、効率的な処理に書き換えることができる気がするけど、現時点では基本的な処理ということで。 String型のAPIがサロゲートペアに対応していない 表示文字数の判定 表示文字数(半角)の取得 表示文字数(半角)の部分文字列 文字列にサロゲ…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fsaku-jp.hatenablog.com%2Fentry%2F2026%2F09%2F05%2F150103&quot; title=&quot;サロゲートペアを意識した文字列操作 - S_a_k_Uの日記みたいなDB&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>2026-09-05 15:01:03</published>
  <title>サロゲートペアを意識した文字列操作</title>
  <type>rich</type>
  <url>https://saku-jp.hatenablog.com/entry/2026/09/05/150103</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
