@@ -19,8 +19,8 @@ Synopsis 29: Builtin Functions
19
19
20
20
Created: 12 Mar 2005
21
21
22
- Last Modified: 20 Nov 2010
23
- Version: 47
22
+ Last Modified: 10 Dec 2010
23
+ Version: 48
24
24
25
25
The document is a draft.
26
26
@@ -293,27 +293,29 @@ C<BUILDALL> routine for the current class, which initializes the object in
293
293
least-derived to most-derived order. See L<S12/Objects>
294
294
for more detailed information on object creation.
295
295
296
+ =item chrs
297
+
298
+ =item ords
299
+
296
300
=item chr
297
301
298
302
=item ord
299
303
304
+ multi sub chrs( Int *@grid --> List of Char )
305
+ multi method ords( Str $string: --> List of Int ) is export
300
306
multi method chr( Int $grid: --> Char ) is export
301
- multi sub chr( Int *@grid --> Char )
302
307
multi method ord( Str $string: --> Int ) is export
303
308
304
- C<chr > takes zero or more integer grapheme ids and returns the
309
+ C<chrs > takes zero or more integer grapheme ids and returns the
305
310
corresponding characters as a string. If any grapheme id is used
306
311
that represents a higher abstraction level than the current
307
312
lexical scope supports, that grapheme is converted to the
308
313
corresponding lower-level string of codepoints/bytes that would
309
314
be appropriate to the current pragmatic context, just as any other Str
310
315
would be downgraded in context.
311
316
312
- C<ord> goes the other direction; it takes a string value and returns
313
- character values as integers. In item context, the return value
314
- is the just the integer value of the first character in the string. In
315
- list context, the return value is the list of integers representing
316
- the entire string. The definition of character is pragma dependent.
317
+ C<ords> goes the other direction; it takes a string value and returns
318
+ character values as integers. The definition of character is pragma dependent.
317
319
Normally it's a grapheme id, but under codepoints or bytes scopes,
318
320
the string is coerced to the appropriate low-level view and interpreted
319
321
as codepoints or bytes. Hence, under "use bytes" you will never see a
@@ -329,6 +331,10 @@ context knows its normalization preferences, and every byte's context
329
331
also knows its encoding preferences. (These are knowable in the
330
332
lexical scope via the $?NF and $?ENC compile-time constants).)
331
333
334
+ The C<chr> and C<ord> variants are restricted to processing a single
335
+ character. As is customary, you may pass a longer string to C<ord>,
336
+ but only the first character will be translated.
337
+
332
338
=item item
333
339
334
340
our Item multi item ( $item )
0 commit comments