Skip to main content

文字列長(size,length)

Python

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

Swift

swift
s.count

Bash

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

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

Ruby

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

C++

cpp
str1.length()