| Chars | categories Primitives Strings |
Objects, Classes and Slots Objects and Entities |
In CLAIRE strings are represented using a C char*, that is a sequence of 8 bit characters. The length of a string is computed by the general method length @ string :
| length("toto") -> 4 |
| s0 :: "a static string" // would compile as a static string s1 :: ("a string" /+ string!('\0') /+ "another string") // dynamically built string |
| s :: "a\0b" // dangerous !!! static string that contain a null (printf("~S\n", length(s))) |
As a general rule, any method that returns a new string returns a dynamic string. This is especially true for the port interface (fread and friends) which is particularly convenient to handle binary streams without having to deal with the null.
| categories | Strings | normal dispatch | operation | Kernel method |
s1 / s2 returns the concatenation of two path components. it is equivalent two s1 /+ *fs* /+ s2 where *fs* is the file separator ('/' under UNIX and '<'>under win32)
| "toto" / "titi" -> "toto/titi". |
| categories | Strings | normal dispatch | operation | Kernel method |
s1 /+ s2 returns a new string that is the concatenation of the two strings.
| "toto" /+ "titi" -> "tototiti". |
| categories | Strings | normal dispatch | operation | [XL] Core method |
s1 /- s2 returns the concatenation of two path components where the last path component of s1 has been removed. For instance
| "toto/tata" /- "titi" -> "toto/titi". |
| categories | Strings | normal dispatch | operation | Kernel method |
returns true if x is lower than y according to the lexicographic order induced by the ASCII order on characters.
| categories | Strings | normal dispatch | operation | Kernel method |
returns true if x is lower or equal to y according to the lexicographic order induced by the ASCII order on characters.
| categories | Strings | normal dispatch | operation | Kernel method |
returns true if x is greater than y according to the lexicographic order induced by the ASCII order on characters.
| categories | Strings | normal dispatch | operation | Kernel method |
returns true if x is greater or equal to y according to the lexicographic order induced by the ASCII order on characters.
| categories | Strings | normal dispatch | [XL] Kernel method |
alpha?(s) returns true if for all char c in s alpha?(c) is true.
| categories | Strings | normal dispatch | Kernel method |
The copy of a string is ... a copy of a string!
| categories | Strings | normal dispatch | [XL] Kernel method |
digit?(s) returns true if for all c in s digit?(c) is true.
| categories | Strings | normal dispatch | [XL] Kernel method |
escape(s) encode the string s according to ISO-8859-1.
| categories | Strings | normal dispatch | [XL] Kernel method |
explode(s, sep) returns the list of substrings of s that are separated by sep. When sep is found at the beginning of the string s an empty match is added to the result list unlike if sep was found at the end of s. Last, if sep isn't found in s the result is a list that contain s as unique element. For instance :
| explode("CLAIRE--CLAIRE","--") -> list<string>("CLAIRE","CLAIRE") explode(";titi;toto",";") -> list<string>("","titi","toto") explode(";titi;toto;",";") -> list<string>("","titi","toto") explode("titi",";") -> list<string>("titi") |
| categories | Strings | normal dispatch | [XL] Kernel method |
like match_wildcard?, explode_wildcard(s, w) matches the string s against the wildcard w. It return the list of matches or nil if the string s doesn't match. A match is made for each '*' and each sequence of '?'. For instance :
| explode_wildcard("CLAIRE", "C*RE") -> list<string>("LAI") explode_wildcard("CLAIRE", "C*TE") -> nil explode_wildcard("CLAIRE", "C???RE") -> list<string>("LAI") explode_wildcard("CLAIRE", "C???TE") -> nil |
| categories | Strings | normal dispatch | [XL] Kernel method |
find(s,x) returns the position in s where the first occurrence of x is found and 0 otherwise.
| find("toto","to") -> 1 find("toto","oto") -> 2 find("toto","ti") -> 0 |
| categories | Strings | normal dispatch | [XL] Kernel method |
find(s,x,from) returns the position in s starting at from where the first occurrence of x is found and 0 otherwise.
| find("toto","to",2) -> 3 find("toto","oto",2) -> 2 find("toto","ti", 2) -> 0 |
| categories | Strings | normal dispatch | Kernel method |
transforms a string into a float.
| categories | Strings | normal dispatch | Kernel method |
get(l, x) returns the lowest i such that s[i] = c (if no such i exists, 0 is returned).
| categories | Strings | normal dispatch | Kernel method |
integer!(s) returns the integer denoted by the string s if s is a string formed by a sign and a succession of digits.
| categories | Strings | normal dispatch | [XL] Kernel method |
left(s,i) is equivalent to substring(s, 1, i).
| left("123456", 2) -> "12" left("6", 2) -> "6" |
| categories | Strings | normal dispatch | Kernel method |
returns the length of a string
| categories | Strings | normal dispatch | [XL] Kernel method |
lower(s) returns a copy of s where all uppercase letters are converted to lowercase.
| categories | Strings | normal dispatch | [XL] Kernel method |
lower?(s) returns true if for all char c in s lower?(c) is true.
| categories | Strings | normal dispatch | [XL] Kernel method |
ltrim(s) (say left trim) returns a copy of s where heading blank chars (' ', '\n', '\t', '\r') have been removed.
| ltrim("toto") -> "toto" ltrim(" toto ") -> "toto " ltrim(" \ttoto\n") -> "toto\n" |
| categories | Strings | normal dispatch | Kernel method |
make_string(i, c) returns a string of length i filled with the character c.
| categories | Strings | normal dispatch | [XL] Kernel method |
match_wildcard?(s, w) returns true if the string s matches the wildcard w. The wildcard is a string that understand special chars :
| match_wildcard?("CLAIRE", "C*RE") -> true match_wildcard?("CLAIRE", "C*TE") -> false match_wildcard?("CLAIRE", "C???RE") -> true match_wildcard?("CLAIRE", "C???TE") -> false |
| categories | Strings | normal dispatch | [XL] Kernel method |
decode the string s that is assumed to be mime encoded (see RFC2047).
| categories | Strings | normal dispatch | [XL] Kernel method |
return a mime encoded representation of s (see RFC2047).
| categories | Strings | inline | Kernel method |
nth(s,i) returns the ithcharacter of the string s. nth(s,i) is equivalent to s[i].
| categories | Strings | inline | Kernel method |
nth=(s,i,c) sets the ithcharacter of the string s to c. nth=(s,i,c) is equivalent to s[i] := c.
| categories | Strings | normal dispatch | [XL] Kernel method |
occurrence(s, z) returns the number of times when the substring z appears in s.
| occurrence("toto", "to") -> 2 occurrence("toto", "tot") -> 1 occurrence("toto", "t1") -> 0 |
| categories | Strings | normal dispatch | [XL] Kernel method |
returns a copy of the string src where all occurrence of s have been replaced by rep.
| replace("toto", "to", "ti") -> "titi" replace("tototiti", "to", "") -> "titi" replace("totitoti", "tot", "t") -> "titi" |
| categories | Strings | normal dispatch | [XL] Kernel method |
find(s,x) returns the position in s where the last occurrence of x is found and 0 otherwise.
| rfind("toto","to") -> 3 rfind("toto","tot") -> 1 rfind("toto","ti") -> 0 |
| categories | Strings | normal dispatch | [XL] Kernel method |
find(s,x,from) returns the position in s where the last occurrence of x is found before the position from and 0 otherwise.
| rfind("toto","to", 4) -> 3 rfind("toto","to", 3) -> 3 rfind("toto","to", 2) -> 1 rfind("toto","ti", 4) -> 0 |
| categories | Strings | normal dispatch | [XL] Kernel method |
right(s,i) is equivalent to substring(s, length(s) - i + 1, length(s)).
| right("123456", 2) -> "56" right("6", 2) -> "6" |
| categories | Strings | normal dispatch | [XL] Kernel method |
rtrim(s) (say right trim) returns a copy of s where tailing blank chars (' ', '\n', '\t', '\r') have been removed.
| rtrim("toto") -> "toto" rtrim(" toto ") -> " toto" rtrim(" \ttoto\n") -> " \ttoto" |
| categories | Strings | normal dispatch | Kernel method |
The method shrink truncates the string s so that its length becomes n. This is a true side-effect and the value returned is always the same as the input.
| let s := "123" in (shrink(s, 2), assert(length(s) = 2)) |
| categories | Strings | normal dispatch | [XL] Kernel method |
space?(s) returns true if for all c in s c is in {' ', '\t', '\r', '\n'}.
space?(" ") -> true
space?("
| categories | Strings | normal dispatch | Kernel method |
substring(s,i,j) returns the substring of s starting at the ithcharacter and ending at the j th. For example :
| substring("CLAIRE", 3, 4) -> "AI" |
| categories | Strings | normal dispatch | Kernel method |
substring(s1,s2,b) returns i if s2 is a subsequence of s1, starting at s1's ithcharacter. The boolean b is there to allow case-sensitiveness or not (identify 'a' and 'A' or not). In case s2 cannot be identified with any subsequence of s1, the returned value is 0.
| categories | Strings | normal dispatch | [XL] Kernel method |
trim(s) returns a copy of s where heading and tailing blank chars (' ', '\n', '\t', '\r') have been removed, one may use ltrim or rtrim that operate on left/right only.
| trim("toto") -> "toto" trim(" toto ") -> "toto" trim(" \ttoto\n") -> "toto" |
| categories | Strings | normal dispatch | [XL] Kernel method |
unescape(s) decode the string s assumed encoded according to ISO-8859-1.
| categories | Strings | normal dispatch | [XL] Kernel method |
returns a copy of the string s where all lowercase letters have been converted to uppercase.
| upper("toto") -> "TOTO" upper("a 1 % @ B") -> "A 1 % @ B" |
| categories | Strings | normal dispatch | [XL] Kernel method |
upper?(s) returns false if it exists a char c in s such c is a lowercase letter
| upper?("toto") -> false upper?("123") -> true upper?("1 % @ B") -> true |
| categories | Strings | normal dispatch | [XL] Kernel method |
url_decode(s) returns a new string that is the decoded version of s according to RFC 1738.
| url_decode("toto") -> "toto" url_decode("toto+titi%3Dtata") -> "toto titi=tata" |
| categories | Strings | normal dispatch | [XL] Kernel method |
url_encode(s) returns a new string that is a representation of s encoded according to RFC 1738.
| url_encode("toto") -> "toto" url_encode("toto titi=tata") -> "toto+titi%3Dtata" |