String length: Difference between revisions
Content added Content deleted
Jazzedpineda (talk | contribs) (Add Plain English) |
m (→{{header|Kotlin}}: made the kotlin example not use java) |
||
Line 1,851: | Line 1,851: | ||
As each UTF-16 character occupies 2 bytes, it follows that the number of bytes occupied by the string will be twice the length: |
As each UTF-16 character occupies 2 bytes, it follows that the number of bytes occupied by the string will be twice the length: |
||
<syntaxhighlight lang=" |
<syntaxhighlight lang="kotlin"> |
||
fun main( |
fun main() { |
||
val s = "José" |
val s = "José" |
||
println("The char length is ${s.length}") |
println("The char length is ${s.length}") |
||
println("The byte length is ${ |
println("The byte length is ${Char.SIZE_BYTES * s.length}") |
||
}</syntaxhighlight> |
}</syntaxhighlight> |
||