# 文字列長(size, length)

# Bash

expr "$str1" : ".*"
${#str1}
expr "abcd" : ".*"     # => 4
echo -n "abcd" | wc -m # => 4

function StringSize
{
    expr "$1" : ".*"
}

# C++

str1.length()

# Python

len(str1)
print len(str1.decode('UTF-8'))  # string size
print len(str1)                  # byte size

# str1 = "あいうえおか"

# Ruby

str1.size
str1.size      # string size
str1.bytesize  # byte size

# str1 = "あいうえおか"

[ 📩 ご意見 ]