LoginSignup
1
1

More than 5 years have passed since last update.

zsh でマルチバイト文字列を測る

Posted at

zsh でマルチバイト文字列の文字数、表示幅、バイト数を調べる方法です。

LANG=ja_JP.utf8
str='ほげほげ'
print ${#str}    # => 4 (文字数)
print ${(m)#str} # => 8 (表示幅)
LANG=C
print ${#str}    # => 12 (バイト数)
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1