String;Utils - Utilities for string processing


    load_bytecode 'String/Utils.pbc'

    .local pmc chomp
               chomp = get_global ['String';'Utils'], 'chomp'

    $S0 = chomp($S0)      # use default record separator ("\n")
    $S0 = chomp($S0, $S1) # use custom record separator

Functions ^

    $S0 = chomp( $S1 )
    $S0 = chomp( $S1, $S2 )
Remove all trailing record separator $S2 from tail of input string $S1 and return in $S0. If $S2 is not specified, the default \n is used.
convert_string_to_int(source [, radix [, pos]])
Convert characters from source starting at pos to an integer according to radix. If pos is specified, start converting at pos, otherwise start from the beginning of the string. radix may be either an integer radix (up to 36) or one of 'x', 'd', 'o', or 'b' to indicate a radix of 16, 10, 8, or 2.Returns the integer value of the converted string, and the number of characters used in the conversion. Conversion stops at the first character that isn't in the valid range according to radix.
    (result, len) = convert_string_to_int('101')           # (101, 3)
    (result, len) = convert_string_to_int('101', 2)        # (5, 3)
    (result, len) = convert_string_to_int('101', 8)        # (65, 3)
    (result, len) = convert_string_to_int('ff', 'x')       # (255, 2)
convert_digits_to_string(source [, radix [, pos])
Converts a decimal, hexadecimal, octal, or binary digit sequence given in source (offset by pos) and according to radix into its corresponding codepoint(s). Returns the converted codepoints and the number of source characters used in the conversion.


 Jerry Gay a.k.a. particle
 Patrick Michaud <>