以下の内容はhttps://tbpgr.hatenablog.com/entry/20141216/1418735006より取得しました。


Ruby | String | bytesize

概要

String#bytesize -> Integer

詳細

文字列のバイト長を整数で返却

サンプルコード
require 'tbpgr_utils'

bulk_puts_eval binding, <<-EOS
"hoge".bytesize
"ほげ".bytesize
"hoげ".bytesize
"hoげ".encoding
"hoげ".encode("Shift_JIS").bytesize
EOS

__END__
下記はTbpgrUtils gemの機能
bulk_puts_eval

https://rubygems.org/gems/tbpgr_utils
https://github.com/tbpgr/tbpgr_utils

出力

"hoge".bytesize                     # => 4
"ほげ".bytesize                     # => 6
"hoげ".bytesize                     # => 5
"hoげ".encoding                     # =>   #<Encoding:UTF-8>
"hoげ".encode("Shift_JIS").bytesize # => 4



以上の内容はhttps://tbpgr.hatenablog.com/entry/20141216/1418735006より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14