user@elli:~/gdx/gdc$ cat tests/string.c
void lpc_main ()
{
string str;
mixed x;
str = "abcd123<XYZ>";
printf ("Str: %s
", str);
printf ("Str[-2..-1]: %s
", str [-2..-1]);
printf ("
");
printf ("Lower case: %s
", lower_case (str));
printf ("Upper case: %s
", upper_case (str));
printf ("Capitalize: %s
", capitalize (str));
printf ("
");
printf ("Str [1 .. 2] = .b.c.
");
printf ("Str: %s
", (str [1 .. 2] = ".b.c."));
printf ("HTML: %s
", htmlspecialchars (str));
printf ("
");
printf ("Str[3..4]: %s
", str [3 .. 4]);
printf ("Crop(str,3,4): %s
", crop_string (str, 3, 4));
printf ("
");
printf ("Str: %s
", str);
printf ("Strpos(str,'c'): %d
", strpos (str, 'c'));
printf ("Strpos(str,\"d1\"): %d
", strpos (str, "d1"));
printf ("Strpos(str,'.'): %d (%c)
", strpos (str, '.'), str [strpos (str, '.')]);
printf ("Strrpos(str,'.'): %d (%c)
", strrpos (str, '.'), str [strrpos (str, '.')]);
printf ("
");
str += str [0];
printf ("Str + str [0]: %s
", str);
str += str [0 .. 0];
printf ("Str + str [0 .. 0]: %s
", str);
printf ("
");
printf ("substr_count(str,a): %d
", substr_count (str, "a"));
printf ("
dirname(str): %s
", dirname (str));
str += "/xyz";
printf ("str: %s
", str);
printf ("dirname(str): %s
", dirname (str));
printf ("str_truncate(str,50): %d bytes: %s
", strlen ((x = str_truncate (str, 50))), x);
printf ("str_truncate(str,5): %d bytes: %s
", strlen ((x = str_truncate (str, 5))), x);
printf ("str_write (str,1,***): %s
", str_write (str, 1, "***"));
printf ("str_write (str,20,***): %s
", str_write (str, 20, "***"));
str == str;
}