OpenSCAD User Manual/String Functions

str
Convert all arguments to strings and concatenate.

Usage examples: number=2; echo ("This is ",number,3," and that's it."); echo (str("This is ",number,3," and that's it."));

Results: ECHO: "This is ", 2, 3, " and that's it." ECHO: "This is 23 and that's it."

This can be used for simple conversion of numbers to strings s = str(n);

chr
Convert numbers to a string containing character with the corresponding code. OpenSCAD uses Unicode, so the number is interpreted as Unicode code point. Numbers outside the valid code point range produce an empty string.

Parameters


 * chr(Number) : Convert one code point to a string of length 1 (number of bytes depending on UTF-8 encoding) if the code point is valid.


 * chr(Vector) : Convert all code points given in the argument vector to a string.


 * chr(Range) : Convert all code points produced by the range argument to a string.

Examples

Note: When used with echo the output to the console for character codes greater than 127 is platform dependent.

ord
Convert a character to a number representing the Unicode code point. If the parameter is not a string, the  returns.

Parameters


 * ord(String) : Convert the first character of the given string to a Unicode code point.

Examples

len
returns the number of characters in a text.

Also See search
search for text searching.

is_string(value)
The function is_string(value) return true if the value is a string, false else

User defined functions
To complement native functions, you can define your own functions, some suggestions: Note here the use of chr to recompose a string from unknown number of caracters defined by their ascii code. This avoid using recursive modules as was required before list management came in.