String length: Difference between revisions

added Julia example
(→‎{{header|Lasso}}: adding Lasso character and byte length size example)
(added Julia example)
Line 1,014:
var str2 = "\uD834\uDD2A"; //U+1D12A represented by a UTF-16 surrogate pair
var len2 = str2.length; //2</lang>
 
=={{header|Julia}}==
Julia encodes strings as UTF-8, so the byte length (via <code>sizeof</code>) will be different from the string length (via <code>length</code>) only if the string contains non-ASCII characters.
 
Byte length:
<lang julia>sizeof("Hello, world!") # gives 13
sizeof("Hellö, wørld!") # gives 15</lang>
Character length:
<lang julia>length("Hello, world!") # gives 13
length("Hellö, wørld!") # gives 13</lang>
 
=={{header|JudoScript}}==
Anonymous user