This is an old revision of the document!


Strings are enclosed in double quotes (“ ”) and are UTF-8 encoded. As with the stock 50g ROM, use of the →STR and STR→ are useful for converting other objects to strings and vice versa. Strings can be cancatenated by the plus (+) operator: “Hello ” “World!” + yields the string “Hello World!”.

Strings in newRPL are always Unicode NFC normalized for maximum compatibility with other devices. Strings imported from other devices should be NFC normalized for proper operation in newRPL. When the source device doesn't guarantee text in a normalized form, this can be done with the →NFC command.


Commands for strings

The following table summarizes commands which can be applied to strings.

Command Purpose Example
→STR Convert to string 45,569 →STR yields “45,569”
STR→ Convert from string to implied object1) “45,569.” STR→ yields 45.569.
→NFC Convert to NFC “Hello World” →NFC yields “Hello World”
UTF8→ Convert each character in string to Unicode UTF8 object “abcd” UTF8→ yields { #61h #62h #63h #64h }
→UTF8 Convert list of Unicode UTF8 objects to a string { #61h #62h #63h #64h } →UTF8 yields “abcd”
SIZE Return the number of characters in a string “Hello World” SIZE yields 11
STRLEN Returns the length of the string, in characters “Hello World” STRLEN yields 11
STRLENCP Returns the length of the string, in characters “Hello World” STRLEN yields 11
POS Returns the position of a substring within a string (0 if not found) “Hello World” “Wor” POS yields 7
POSREV Returns the position of the substring counting from end of sting (0 if not found) “Hello World” “Wor” POSREV yields 3
NPOS
NPOSREV
SREV Reverse the string “Hello World” SREV yields “dlroW olleH”
REPL Replace part of a string with another at the specified position “Hello World” 7 “Universe” REPL yields “Hello Universe”
SREPL
SUB
HEAD
TAIL
TRIM
RTRIM
NTOKENS
NTHTOKEN
NTHTOKENPOS


1)
In this case, OBJ→ can also be used.
  • manual/chapter3/strings.1504385416.txt.gz
  • Last modified: 2017/09/02 13:50
  • by smartin