Search code examples
rascal

Length in bytes of a String


Is there a function in the Rascal Lib where I get the length in bytes of a String?

A bit similar as the getFileLength() function in IO.

I need it for setting an offset in a Location value.


Solution

  • Yes! http://tutor.rascal-mpl.org/Rascal/Rascal.html#/Rascal/Libraries/Prelude/String/size/size.html

    The size function does exactly what you need:

    . size("was") == 3