#elixir
We can also get the number of bytes in a string:
iex > byte_size ( "hellö" ) 6
Notice that the number of bytes in that string is 6, even though it has 5 graphemes. That’s because the grapheme “ö” takes 2 bytes to be represented in UTF-8. We can get the actual length of the string, based on the number of graphemes, by using the String.length/1
function:
iex > String . length ( "hellö" ) 5
If you want to change selection, open document below and click on "Move attachment"
Basic types - The Elixir programming languagethat the IO.puts/1 function returns the atom :ok after printing. Strings in Elixir are represented internally by contiguous sequences of bytes known as binaries: iex> is_binary("hellö") true <span>We can also get the number of bytes in a string: iex> byte_size("hellö") 6 Notice that the number of bytes in that string is 6, even though it has 5 graphemes. That’s because the grapheme “ö” takes 2 bytes to be represented in UTF-8. We can get the actual length of the string, based on the number of graphemes, by using the String.length/1 function: iex> String.length("hellö") 5 The String module contains a bunch of functions that operate on strings as defined in the Unicode standard: iex> String.upcase("hellö") "HELLÖ" Anonymous functions Elixir also provid Summary
status | not read | | reprioritisations | |
---|
last reprioritisation on | | | suggested re-reading day | |
---|
started reading on | | | finished reading on | |
---|
Details