Module: Toybox::StringUtil

Overview

The StringUtil module contains String utility functions

Since:

  • 1.3.0

Defined Under Namespace

Classes: InvalidHexStringException

Constant Summary

CHAR_ENCODING_UTF8 = 0

Since:

  • 3.0.0

REPRESENTATION_STRING_BASE64 = 0

Since:

  • 3.0.0

REPRESENTATION_STRING_HEX = 1

Since:

  • 3.0.0

REPRESENTATION_STRING_PLAIN_TEXT = 2

Since:

  • 3.0.0

REPRESENTATION_BYTE_ARRAY = 3

Since:

  • 3.0.0

Instance Method Summary collapse

Instance Method Details

charArrayToString(charArray) ⇒ Toybox::Lang::String

Given an Array of Char objects, return the String equivalent

Parameters:

Returns:

Since:

  • 1.3.0


10485
10486
# File 'Monkeybrains.rb', line 10485

def charArrayToString(charArray)
end

convertEncodedString(input, options) ⇒ Toybox::Lang::String, Toybox::Lang::ByteArray

Convert a String or ByteArray representation to a String or ByteArray representation whose underlying byte format corresponds to the provided input options.

Parameters:

Options Hash (options):

  • :fromRepresentation (Toybox::Lang::Number)

    Required. A REPRESENTATION_* enum value indicating the representation from which the input should be converted.

  • :toRepresentation (Toybox::Lang::Number)

    Required. A REPRESENTATION_* enum value indicating the representation to which the input should be converted.

  • :encoding (Toybox::Lang::Number)

    A CHAR_ENCODING_* value indicating the String encoding to use when generating a hex string or ByteArray when either the fromRepresentation or toRepresentation is set to REPRESENTATION_STRING_PLAIN_TEXT. Defaults to CHAR_ENCODING_UTF8 if not specified.

Returns:

Raises:

Since:

  • 3.0.0


10525
10526
# File 'Monkeybrains.rb', line 10525

def convertEncodedString(input, options)
end

encodeBase64(string) ⇒ Toybox::Lang::String

Encodes a String in base64

Parameters:

Returns:

Since:

  • 1.3.0


10499
10500
# File 'Monkeybrains.rb', line 10499

def encodeBase64(string)
end

utf8ArrayToString(utf8Array) ⇒ Toybox::Lang::String

Given an Array of UTF-8 bytes, return the String equivalent

Parameters:

Returns:

Since:

  • 1.3.0


10492
10493
# File 'Monkeybrains.rb', line 10492

def utf8ArrayToString(utf8Array)
end