Table of Contents

  1. String

<lol/base/string.h>

View this file in the source browser: trunk/src/lol/base/string.h

String

The String class encapsulates an array of chars representing UTF-8 characters.

Strings can be constructed from other strings or from C-style strings:

String s1;           /* Will be empty */
String s2("ABC");    /* Will contain "ABC" */
String s3("ABC", 2); /* Will contain "AB" */
String s4(s3);       /* Will contain "AB" */

The length specifier helps building strings containing the null char:

String s1("abc\0def");    /* Will contain "abc" */
String s2("abc\0def", 7); /* Will contain "abc\0def" */

The contents of a string can be accessed as a constant C string using the C() accessor:

String s("Hello!");
printf("%s\n", s.C());
Last modified 10 years ago Last modified on Feb 6, 2013, 12:58:22 AM