AT&T Home | AT&T Labs | Research
AT&T Labs, Inc. - Research

The Yoix® Scripting Language

Home | What's New | Grammar | Documentation | Download | License | YChart | YDAT | YWAIT | Byzgraf | FAQs
utf8len (String str) yoix.string
 
Returns the number of bytes resulting from a UTF-8 encoding of str. The UTF-8 encoding itself is not performed. One instance where this information is useful occurs when determining if strings in a ZipEntry will exceed the allowed maximum byte lengths.
 
 Example:   Refer to the documentation for offsetBytes to see an example of offsetSupported usage.
 
 Example:   The following script determines the number of bytes needed for a UTF-8 encoding of some German text.
import yoix.stdio.*;
import yoix.string.*;

String joy = "O, Freunde, nicht diese Töne!\n\
Sondern laß uns angenehmere\n\
anstimmen, und freudenvollere.\n\
\n\
Freude, schöner Götterfunken\n\
Tochter aus Elysium.\n\
Wir betreten freuertrunken,\n\
Himmlische, dein Heiligtum!\n\
Deine Zauber binden wieder,\n\
Was die Mode streng geteilt;\n\
Alle Menschen werden Brüder,\n\
Wo dein sanfter Flügel weilt.\n";

fprintf(stdout,
	"String Length: %d\nUTF-8 Length: %d\n",
	joy@length, utf8len(joy));
The result on standard output is shown below:
String Length: 312
UTF-8 Length: 318
 
 Return:   int
 
 See Also:   ZipEntry

 

Yoix is a registered trademark of AT&T Inc.