1Clownfish::String(3)  User Contributed Perl Documentation Clownfish::String(3)
2
3
4

NAME

6       Clownfish::String - Immutable string holding Unicode characters.
7

SYNOPSIS

9           my $string = Clownfish::String->new('abc');
10           print $string->to_perl, "\n";
11

DESCRIPTION

CONSTRUCTORS

14   new
15           my $string = Clownfish::String->new($perl_string);
16
17       Return a String containing the passed-in Perl string.
18

METHODS

20   cat
21           my $result = $string->cat($other);
22
23       Return the concatenation of the String and "other".
24
25   to_i64
26           my $int = $string->to_i64();
27
28       Extract a 64-bit integer from a decimal string.  See basex_to_i64() for
29       details.
30
31   basex_to_i64
32           my $int = $string->basex_to_i64($base);
33
34       Extract a 64-bit integer from a variable-base stringified version.
35       Expects an optional minus sign followed by base-x digits, stopping at
36       any non-digit character.  Returns zero if no digits are found.  If the
37       value exceeds the range of an "int64_t", the result is undefined.
38
39base - A base between 2 and 36.
40
41   to_f64
42           my $float = $string->to_f64();
43
44       Convert a string to a floating-point number using the C library
45       function "strtod".
46
47   starts_with
48           my $bool = $string->starts_with($prefix);
49
50       Test whether the String starts with "prefix".
51
52   ends_with
53           my $bool = $string->ends_with($suffix);
54
55       Test whether the String ends with "suffix".
56
57   contains
58           my $bool = $string->contains($substring);
59
60       Test whether the String contains "substring".
61
62   find
63           my $string_iterator = $string->find($substring);
64
65       Return a StringIterator pointing to the first occurrence of "substring"
66       within the String, or undef if the substring does not match.
67
68   length
69           my $int = $string->length();
70
71       Return the number of Unicode code points the String contains.
72
73   get_size
74           my $int = $string->get_size();
75
76       Return the number of bytes occupied by the String’s internal content.
77
78   to_bytebuf
79           my $byte_buf = $string->to_bytebuf();
80
81       Return a ByteBuf which holds a copy of the String.
82
83   clone
84           my $result = $string->clone();
85
86       Return a clone of the object.
87
88   compare_to
89           my $int = $string->compare_to($other);
90
91       Indicate whether one String is less than, equal to, or greater than
92       another.  The Unicode code points of the Strings are compared
93       lexicographically.  Throws an exception if "other" is not a String.
94
95       Returns: 0 if the Strings are equal, a negative number if "self" is
96       less than "other", and a positive number if "self" is greater than
97       "other".
98
99   trim
100           my $result = $string->trim();
101
102       Return a copy of the String with Unicode whitespace characters removed
103       from both top and tail.  Whitespace is any character that has the
104       Unicode property "White_Space".
105
106   trim_top
107           my $result = $string->trim_top();
108
109       Return a copy of the String with leading Unicode whitespace removed.
110       Whitespace is any character that has the Unicode property
111       "White_Space".
112
113   trim_tail
114           my $result = $string->trim_tail();
115
116       Return a copy of the String with trailing Unicode whitespace removed.
117       Whitespace is any character that has the Unicode property
118       "White_Space".
119
120   code_point_at
121           my $int = $string->code_point_at($tick);
122
123       Return the Unicode code point located "tick" code points in from the
124       top.  Return "CFISH_STR_OOB" if out of bounds.
125
126   code_point_from
127           my $int = $string->code_point_from($tick);
128
129       Return the Unicode code point located "tick" code points counting
130       backwards from the end.  Return "CFISH_STR_OOB" if out of bounds.
131
132   substring
133           my $result = $string->substring(
134               offset => $offset,  # required
135               length => $length,  # required
136           );
137
138       Return a new substring containing a copy of the specified range.
139
140offset - Offset from the top, in code points.
141
142length - The desired length of the substring, in code points.
143
144   top
145           my $string_iterator = $string->top();
146
147       Return an iterator initialized to the start of the string.
148
149   tail
150           my $string_iterator = $string->tail();
151
152       Return an iterator initialized to the end of the string.
153

INHERITANCE

155       Clownfish::String isa Clownfish::Obj.
156
157
158
159perl v5.36.0                      2023-01-20              Clownfish::String(3)
Impressum