str_at(src, index)

Provides direct access to the bytes of a string.

This script returns a string containing the byte in the source string at the position corresponding to the specified index. It may not correspond to an actual character in case of strings with special encoded character (i.e. multi-byte or variable-length encoding)

The string is zero-indexed.

Parameters

src: source string.

index: integer specifying the position inside the source string.

Return Value

String containing the byte at position index in the source string. An exception is raised if the index is not valid.

Example command:

  • str_at("Hello", 0)
    • returns "H"
  • str_at("Hello", 1)
    • returns "e"
  • str_at("Hello", 10)
    • error (index out of bound)
  • str_at("", 0)
    • error (source string is empty)