String :: insert - Insert into String
The function inserts the string cString at the position passed in iPosition (units) and returns a reference to the string.
When the position passed is greater than lengthInUnits() , the string content is first extended with blanks.
When the position passed is less than zero, the function throws an exception.
The coding type of the result depends on the string coding type of the calling string. When encoding types of the strings differ, a copy of the string passed in cString is recoded to the encoding type of the calling string before performing the operation..
odaba::String str = "Meal";
str.insert(1,"ontr");
// str == "Montreal"
str.insert(10,"!!");
// str == "Montreal !!"
Implementation details
- iPosition
- Position in collection
The position of an element in a collection is beginning with 0 for the first element.
- cString
- Constant string object
When iPosition exceeds the string length or when the string is empty, the the function returns -1 (lower).