Upgrade to Pro — share decks privately, control downloads, hide ads and more …

文字ときどきRuby / Character and Ruby

文字ときどきRuby / Character and Ruby

とみたまさひろ

December 09, 2023
Tweet

More Decks by とみたまさひろ

Other Decks in Technology

Transcript

  1. 「髙」 > '髙'.encode('Windows-31J') "\x{FBFC}" > '髙'.encode('SJIS') # SJIS は Windows-31J

    の別名 "\x{FBFC}" > '髙'.encode('Shift_JIS') # Shift_JIS と SJIS は異なる # `encode': U+9AD9 from UTF-8 to Shift_JIS # (Encoding::UndefinedConversionError) 20
  2. Ruby で書記素を扱う 正規表現 \X > ' '.scan(/./) [" ", "

    ", " ", " ", "", " ", "", " ", "", " "] > ' '.scan(/\X/) [" ", " ", " "] 37