0
str1 = "LIMITEDESCRITøRIO" 
str2 = "RITøRIO"
str3 = "øRIO"
echo "Length = $str1 $str2 $str3"

Result: 
Length = 13 4 1 

Length is getting calculated only till the occurrence of special character. And the rest are ignored.

Can anyone pls explain the reason behind this and also give me the solution to calculate the length of full string that contains special character.

Udhayakumar
  • 41
  • 1
  • 4
  • Possible duplicate of [Length of string in bash](http://stackoverflow.com/questions/17368067/length-of-string-in-bash) – jofel Jan 18 '16 at 11:31
  • 1
    What language is this? – n. m. could be an AI Jan 18 '16 at 11:33
  • 1
    Which shell are you using? The syntax you wrote does not work in most shells. Please clarify your question. – jofel Jan 18 '16 at 11:33
  • Well it clearly can't be bash - there are spaces around the "=", the Result would be just those strings, not their lengths, however wrong. It's not perl either.. maybe PHP (I have almost no experience with PHP)? – Jan Spurny Jan 18 '16 at 11:34

1 Answers1

0

Try using:

$ str1="LIMITEDESCRITøRIO"
$ len=${#str1}
$ echo "Length of string \"${str1}\" is ${len}."

Length of string "LIMITEDESCRITøRIO" is 17.
Idos
  • 15,053
  • 14
  • 60
  • 75