1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module glib.Str;
26 
27 private import core.stdc.stdio;
28 private import core.stdc.string;
29 private import glib.Str;
30 private import gtkc.glib;
31 public  import gtkc.glibtypes;
32 public  import gtkc.gobjecttypes;
33 
34 
35 /** */
36 public struct Str
37 {
38 	/*
39 	 * Convert C-style 0 terminated string s to char[] string.
40 	 * copied from phobos
41 	 */
42 	public static string toString(const(char)* s, size_t len = 0)
43 	{
44 		if ( s is null )
45 			return cast(string)null;
46 		
47 		if ( len == 0 )
48 			len = strlen(s);
49 		
50 		return s[0 .. len].idup;
51 	}
52 	
53 	/*
54 	 * Convert array of chars s[] to a C-style 0 terminated string.
55 	 * copied from phobos
56 	 */
57 	public static char* toStringz(string s)
58 	{
59 		if ( s is null ) return null;
60 		char[] copy;
61 		
62 		if (s.length == 0)
63 		{
64 			copy = "\0".dup;
65 		}
66 		else
67 		{
68 			// Need to make a copy
69 			copy = new char[s.length + 1];
70 			copy[0..s.length] = s[];
71 			copy[s.length] = 0;
72 		}
73 		
74 		return copy.ptr;
75 	}
76 	
77 	/** */
78 	public static char** toStringzArray(string[] args)
79 	{
80 		if ( args is null )
81 		{
82 			return null;
83 		}
84 		char** argv = (new char*[args.length]).ptr;
85 		int argc = 0;
86 		foreach (string p; args)
87 		{
88 			argv[argc++] = cast(char*)(p.dup~'\0');
89 		}
90 		argv[argc] = null;
91 		
92 		return argv;
93 	}
94 	
95 	/** */
96 	public static char*** toStringzArray(string[][] args)
97 	{
98 		if ( args is null )
99 		{
100 			return null;
101 		}
102 		char**[] argv = new char**[args.length];
103 		int argc = 0;
104 		foreach( string[] p; args )
105 		{
106 			argv[argc++] = toStringzArray(p);
107 		}
108 		argv[argc] = null;
109 		
110 		return argv.ptr;
111 	}
112 	
113 	/** */
114 	public static string[] toStringArray(const(char*)* args)
115 	{
116 		if ( args is null )
117 		{
118 			return null;
119 		}
120 		string[] argv;
121 		
122 		while ( *args !is null )
123 		{
124 			argv ~= toString(*args);
125 			args++;
126 		}
127 		
128 		return argv;
129 	}
130 	
131 	/** */
132 	public static string[] toStringArray(const(char*)* args, size_t len)
133 	{
134 		string[] argv = new string[len];
135 		
136 		for ( int i; i < len; i++ )
137 		{
138 			argv[i] = toString(args[i]);
139 		}
140 		
141 		return argv;
142 	}
143 	
144 	/** */
145 	public static string[][] toStringArray(char*** args)
146 	{
147 		string[][] argv;
148 		
149 		if ( args is null )
150 		{
151 			return null;
152 		}
153 		
154 		while ( *args !is null )
155 		{
156 			argv ~= toStringArray(*args);
157 			args++;
158 		}
159 		
160 		return argv;
161 	}
162 	
163 	/** */
164 	public static void freeString(char* str)
165 	{
166 		g_free(str);
167 	}
168 	
169 	/** */
170 	public static void freeStringArray(char** str)
171 	{
172 		g_strfreev(str);
173 	}
174 	
175 	/** */
176 	public static void freeStringArray(char*** str)
177 	{
178 		while ( *str !is null )
179 		{
180 			g_strfreev(*str);
181 			str++;
182 		}
183 		
184 		g_free(str);
185 	}
186 
187 	/**
188 	 */
189 
190 	/**
191 	 * Determines the numeric value of a character as a decimal digit.
192 	 * Differs from g_unichar_digit_value() because it takes a char, so
193 	 * there's no worry about sign extension if characters are signed.
194 	 *
195 	 * Params:
196 	 *     c = an ASCII character
197 	 *
198 	 * Return: If @c is a decimal digit (according to g_ascii_isdigit()),
199 	 *     its numeric value. Otherwise, -1.
200 	 */
201 	public static int asciiDigitValue(char c)
202 	{
203 		return g_ascii_digit_value(c);
204 	}
205 
206 	/**
207 	 * Converts a #gdouble to a string, using the '.' as
208 	 * decimal point.
209 	 *
210 	 * This function generates enough precision that converting
211 	 * the string back using g_ascii_strtod() gives the same machine-number
212 	 * (on machines with IEEE compatible 64bit doubles). It is
213 	 * guaranteed that the size of the resulting string will never
214 	 * be larger than @G_ASCII_DTOSTR_BUF_SIZE bytes, including the terminating
215 	 * nul character, which is always added.
216 	 *
217 	 * Params:
218 	 *     buffer = A buffer to place the resulting string in
219 	 *     bufLen = The length of the buffer.
220 	 *     d = The #gdouble to convert
221 	 *
222 	 * Return: The pointer to the buffer with the converted string.
223 	 */
224 	public static string asciiDtostr(string buffer, int bufLen, double d)
225 	{
226 		auto retStr = g_ascii_dtostr(Str.toStringz(buffer), bufLen, d);
227 		
228 		scope(exit) Str.freeString(retStr);
229 		return Str.toString(retStr);
230 	}
231 
232 	/**
233 	 * Converts a #gdouble to a string, using the '.' as
234 	 * decimal point. To format the number you pass in
235 	 * a printf()-style format string. Allowed conversion
236 	 * specifiers are 'e', 'E', 'f', 'F', 'g' and 'G'.
237 	 *
238 	 * The returned buffer is guaranteed to be nul-terminated.
239 	 *
240 	 * If you just want to want to serialize the value into a
241 	 * string, use g_ascii_dtostr().
242 	 *
243 	 * Params:
244 	 *     buffer = A buffer to place the resulting string in
245 	 *     bufLen = The length of the buffer.
246 	 *     format = The printf()-style format to use for the
247 	 *         code to use for converting.
248 	 *     d = The #gdouble to convert
249 	 *
250 	 * Return: The pointer to the buffer with the converted string.
251 	 */
252 	public static string asciiFormatd(string buffer, int bufLen, string format, double d)
253 	{
254 		auto retStr = g_ascii_formatd(Str.toStringz(buffer), bufLen, Str.toStringz(format), d);
255 		
256 		scope(exit) Str.freeString(retStr);
257 		return Str.toString(retStr);
258 	}
259 
260 	/**
261 	 * Compare two strings, ignoring the case of ASCII characters.
262 	 *
263 	 * Unlike the BSD strcasecmp() function, this only recognizes standard
264 	 * ASCII letters and ignores the locale, treating all non-ASCII
265 	 * bytes as if they are not letters.
266 	 *
267 	 * This function should be used only on strings that are known to be
268 	 * in encodings where the bytes corresponding to ASCII letters always
269 	 * represent themselves. This includes UTF-8 and the ISO-8859-*
270 	 * charsets, but not for instance double-byte encodings like the
271 	 * Windows Codepage 932, where the trailing bytes of double-byte
272 	 * characters include all ASCII letters. If you compare two CP932
273 	 * strings using this function, you will get false matches.
274 	 *
275 	 * Both @s1 and @s2 must be non-%NULL.
276 	 *
277 	 * Params:
278 	 *     s1 = string to compare with @s2
279 	 *     s2 = string to compare with @s1
280 	 *
281 	 * Return: 0 if the strings match, a negative value if @s1 < @s2,
282 	 *     or a positive value if @s1 > @s2.
283 	 */
284 	public static int asciiStrcasecmp(string s1, string s2)
285 	{
286 		return g_ascii_strcasecmp(Str.toStringz(s1), Str.toStringz(s2));
287 	}
288 
289 	/**
290 	 * Converts all upper case ASCII letters to lower case ASCII letters.
291 	 *
292 	 * Params:
293 	 *     str = a string
294 	 *     len = length of @str in bytes, or -1 if @str is nul-terminated
295 	 *
296 	 * Return: a newly-allocated string, with all the upper case
297 	 *     characters in @str converted to lower case, with semantics that
298 	 *     exactly match g_ascii_tolower(). (Note that this is unlike the
299 	 *     old g_strdown(), which modified the string in place.)
300 	 */
301 	public static string asciiStrdown(string str, ptrdiff_t len)
302 	{
303 		auto retStr = g_ascii_strdown(Str.toStringz(str), len);
304 		
305 		scope(exit) Str.freeString(retStr);
306 		return Str.toString(retStr);
307 	}
308 
309 	/**
310 	 * Compare @s1 and @s2, ignoring the case of ASCII characters and any
311 	 * characters after the first @n in each string.
312 	 *
313 	 * Unlike the BSD strcasecmp() function, this only recognizes standard
314 	 * ASCII letters and ignores the locale, treating all non-ASCII
315 	 * characters as if they are not letters.
316 	 *
317 	 * The same warning as in g_ascii_strcasecmp() applies: Use this
318 	 * function only on strings known to be in encodings where bytes
319 	 * corresponding to ASCII letters always represent themselves.
320 	 *
321 	 * Params:
322 	 *     s1 = string to compare with @s2
323 	 *     s2 = string to compare with @s1
324 	 *     n = number of characters to compare
325 	 *
326 	 * Return: 0 if the strings match, a negative value if @s1 < @s2,
327 	 *     or a positive value if @s1 > @s2.
328 	 */
329 	public static int asciiStrncasecmp(string s1, string s2, size_t n)
330 	{
331 		return g_ascii_strncasecmp(Str.toStringz(s1), Str.toStringz(s2), n);
332 	}
333 
334 	/**
335 	 * Converts a string to a #gdouble value.
336 	 *
337 	 * This function behaves like the standard strtod() function
338 	 * does in the C locale. It does this without actually changing
339 	 * the current locale, since that would not be thread-safe.
340 	 * A limitation of the implementation is that this function
341 	 * will still accept localized versions of infinities and NANs.
342 	 *
343 	 * This function is typically used when reading configuration
344 	 * files or other non-user input that should be locale independent.
345 	 * To handle input from the user you should normally use the
346 	 * locale-sensitive system strtod() function.
347 	 *
348 	 * To convert from a #gdouble to a string in a locale-insensitive
349 	 * way, use g_ascii_dtostr().
350 	 *
351 	 * If the correct value would cause overflow, plus or minus %HUGE_VAL
352 	 * is returned (according to the sign of the value), and %ERANGE is
353 	 * stored in %errno. If the correct value would cause underflow,
354 	 * zero is returned and %ERANGE is stored in %errno.
355 	 *
356 	 * This function resets %errno before calling strtod() so that
357 	 * you can reliably detect overflow and underflow.
358 	 *
359 	 * Params:
360 	 *     nptr = the string to convert to a numeric value.
361 	 *     endptr = if non-%NULL, it returns the
362 	 *         character after the last character used in the conversion.
363 	 *
364 	 * Return: the #gdouble value.
365 	 */
366 	public static double asciiStrtod(string nptr, out string endptr)
367 	{
368 		char* outendptr = null;
369 		
370 		auto p = g_ascii_strtod(Str.toStringz(nptr), &outendptr);
371 		
372 		endptr = Str.toString(outendptr);
373 		
374 		return p;
375 	}
376 
377 	/**
378 	 * Converts a string to a #gint64 value.
379 	 * This function behaves like the standard strtoll() function
380 	 * does in the C locale. It does this without actually
381 	 * changing the current locale, since that would not be
382 	 * thread-safe.
383 	 *
384 	 * This function is typically used when reading configuration
385 	 * files or other non-user input that should be locale independent.
386 	 * To handle input from the user you should normally use the
387 	 * locale-sensitive system strtoll() function.
388 	 *
389 	 * If the correct value would cause overflow, %G_MAXINT64 or %G_MININT64
390 	 * is returned, and `ERANGE` is stored in `errno`.
391 	 * If the base is outside the valid range, zero is returned, and
392 	 * `EINVAL` is stored in `errno`. If the
393 	 * string conversion fails, zero is returned, and @endptr returns @nptr
394 	 * (if @endptr is non-%NULL).
395 	 *
396 	 * Params:
397 	 *     nptr = the string to convert to a numeric value.
398 	 *     endptr = if non-%NULL, it returns the
399 	 *         character after the last character used in the conversion.
400 	 *     base = to be used for the conversion, 2..36 or 0
401 	 *
402 	 * Return: the #gint64 value or zero on error.
403 	 *
404 	 * Since: 2.12
405 	 */
406 	public static long asciiStrtoll(string nptr, out string endptr, uint base)
407 	{
408 		char* outendptr = null;
409 		
410 		auto p = g_ascii_strtoll(Str.toStringz(nptr), &outendptr, base);
411 		
412 		endptr = Str.toString(outendptr);
413 		
414 		return p;
415 	}
416 
417 	/**
418 	 * Converts a string to a #guint64 value.
419 	 * This function behaves like the standard strtoull() function
420 	 * does in the C locale. It does this without actually
421 	 * changing the current locale, since that would not be
422 	 * thread-safe.
423 	 *
424 	 * This function is typically used when reading configuration
425 	 * files or other non-user input that should be locale independent.
426 	 * To handle input from the user you should normally use the
427 	 * locale-sensitive system strtoull() function.
428 	 *
429 	 * If the correct value would cause overflow, %G_MAXUINT64
430 	 * is returned, and `ERANGE` is stored in `errno`.
431 	 * If the base is outside the valid range, zero is returned, and
432 	 * `EINVAL` is stored in `errno`.
433 	 * If the string conversion fails, zero is returned, and @endptr returns
434 	 * @nptr (if @endptr is non-%NULL).
435 	 *
436 	 * Params:
437 	 *     nptr = the string to convert to a numeric value.
438 	 *     endptr = if non-%NULL, it returns the
439 	 *         character after the last character used in the conversion.
440 	 *     base = to be used for the conversion, 2..36 or 0
441 	 *
442 	 * Return: the #guint64 value or zero on error.
443 	 *
444 	 * Since: 2.2
445 	 */
446 	public static ulong asciiStrtoull(string nptr, out string endptr, uint base)
447 	{
448 		char* outendptr = null;
449 		
450 		auto p = g_ascii_strtoull(Str.toStringz(nptr), &outendptr, base);
451 		
452 		endptr = Str.toString(outendptr);
453 		
454 		return p;
455 	}
456 
457 	/**
458 	 * Converts all lower case ASCII letters to upper case ASCII letters.
459 	 *
460 	 * Params:
461 	 *     str = a string
462 	 *     len = length of @str in bytes, or -1 if @str is nul-terminated
463 	 *
464 	 * Return: a newly allocated string, with all the lower case
465 	 *     characters in @str converted to upper case, with semantics that
466 	 *     exactly match g_ascii_toupper(). (Note that this is unlike the
467 	 *     old g_strup(), which modified the string in place.)
468 	 */
469 	public static string asciiStrup(string str, ptrdiff_t len)
470 	{
471 		auto retStr = g_ascii_strup(Str.toStringz(str), len);
472 		
473 		scope(exit) Str.freeString(retStr);
474 		return Str.toString(retStr);
475 	}
476 
477 	/**
478 	 * Convert a character to ASCII lower case.
479 	 *
480 	 * Unlike the standard C library tolower() function, this only
481 	 * recognizes standard ASCII letters and ignores the locale, returning
482 	 * all non-ASCII characters unchanged, even if they are lower case
483 	 * letters in a particular character set. Also unlike the standard
484 	 * library function, this takes and returns a char, not an int, so
485 	 * don't call it on %EOF but no need to worry about casting to #guchar
486 	 * before passing a possibly non-ASCII character in.
487 	 *
488 	 * Params:
489 	 *     c = any character
490 	 *
491 	 * Return: the result of converting @c to lower case. If @c is
492 	 *     not an ASCII upper case letter, @c is returned unchanged.
493 	 */
494 	public static char asciiTolower(char c)
495 	{
496 		return g_ascii_tolower(c);
497 	}
498 
499 	/**
500 	 * Convert a character to ASCII upper case.
501 	 *
502 	 * Unlike the standard C library toupper() function, this only
503 	 * recognizes standard ASCII letters and ignores the locale, returning
504 	 * all non-ASCII characters unchanged, even if they are upper case
505 	 * letters in a particular character set. Also unlike the standard
506 	 * library function, this takes and returns a char, not an int, so
507 	 * don't call it on %EOF but no need to worry about casting to #guchar
508 	 * before passing a possibly non-ASCII character in.
509 	 *
510 	 * Params:
511 	 *     c = any character
512 	 *
513 	 * Return: the result of converting @c to upper case. If @c is not
514 	 *     an ASCII lower case letter, @c is returned unchanged.
515 	 */
516 	public static char asciiToupper(char c)
517 	{
518 		return g_ascii_toupper(c);
519 	}
520 
521 	/**
522 	 * Determines the numeric value of a character as a hexidecimal
523 	 * digit. Differs from g_unichar_xdigit_value() because it takes
524 	 * a char, so there's no worry about sign extension if characters
525 	 * are signed.
526 	 *
527 	 * Params:
528 	 *     c = an ASCII character.
529 	 *
530 	 * Return: If @c is a hex digit (according to g_ascii_isxdigit()),
531 	 *     its numeric value. Otherwise, -1.
532 	 */
533 	public static int asciiXdigitValue(char c)
534 	{
535 		return g_ascii_xdigit_value(c);
536 	}
537 
538 	/**
539 	 * Calculates the maximum space needed to store the output
540 	 * of the sprintf() function.
541 	 *
542 	 * Params:
543 	 *     format = the format string. See the printf() documentation
544 	 *     args = the parameters to be inserted into the format string
545 	 *
546 	 * Return: the maximum space needed to store the formatted string
547 	 */
548 	public static size_t printfStringUpperBound(string format, void* args)
549 	{
550 		return g_printf_string_upper_bound(Str.toStringz(format), args);
551 	}
552 
553 	/**
554 	 * Copies a nul-terminated string into the dest buffer, include the
555 	 * trailing nul, and return a pointer to the trailing nul byte.
556 	 * This is useful for concatenating multiple strings together
557 	 * without having to repeatedly scan for the end.
558 	 *
559 	 * Params:
560 	 *     dest = destination buffer.
561 	 *     src = source string.
562 	 *
563 	 * Return: a pointer to trailing nul byte.
564 	 */
565 	public static string stpcpy(string dest, string src)
566 	{
567 		auto retStr = g_stpcpy(Str.toStringz(dest), Str.toStringz(src));
568 		
569 		scope(exit) Str.freeString(retStr);
570 		return Str.toString(retStr);
571 	}
572 
573 	/**
574 	 * Looks whether the string @str begins with @prefix.
575 	 *
576 	 * Params:
577 	 *     str = a nul-terminated string
578 	 *     prefix = the nul-terminated prefix to look for
579 	 *
580 	 * Return: %TRUE if @str begins with @prefix, %FALSE otherwise.
581 	 *
582 	 * Since: 2.2
583 	 */
584 	public static bool hasPrefix(string str, string prefix)
585 	{
586 		return g_str_has_prefix(Str.toStringz(str), Str.toStringz(prefix)) != 0;
587 	}
588 
589 	/**
590 	 * Looks whether the string @str ends with @suffix.
591 	 *
592 	 * Params:
593 	 *     str = a nul-terminated string
594 	 *     suffix = the nul-terminated suffix to look for
595 	 *
596 	 * Return: %TRUE if @str end with @suffix, %FALSE otherwise.
597 	 *
598 	 * Since: 2.2
599 	 */
600 	public static bool hasSuffix(string str, string suffix)
601 	{
602 		return g_str_has_suffix(Str.toStringz(str), Str.toStringz(suffix)) != 0;
603 	}
604 
605 	/**
606 	 * Determines if a string is pure ASCII. A string is pure ASCII if it
607 	 * contains no bytes with the high bit set.
608 	 *
609 	 * Params:
610 	 *     str = a string
611 	 *
612 	 * Return: %TRUE if @str is ASCII
613 	 *
614 	 * Since: 2.40
615 	 */
616 	public static bool isAscii(string str)
617 	{
618 		return g_str_is_ascii(Str.toStringz(str)) != 0;
619 	}
620 
621 	/**
622 	 * Checks if a search conducted for @search_term should match
623 	 * @potential_hit.
624 	 *
625 	 * This function calls g_str_tokenize_and_fold() on both
626 	 * @search_term and @potential_hit.  ASCII alternates are never taken
627 	 * for @search_term but will be taken for @potential_hit according to
628 	 * the value of @accept_alternates.
629 	 *
630 	 * A hit occurs when each folded token in @search_term is a prefix of a
631 	 * folded token from @potential_hit.
632 	 *
633 	 * Depending on how you're performing the search, it will typically be
634 	 * faster to call g_str_tokenize_and_fold() on each string in
635 	 * your corpus and build an index on the returned folded tokens, then
636 	 * call g_str_tokenize_and_fold() on the search term and
637 	 * perform lookups into that index.
638 	 *
639 	 * As some examples, searching for "fred" would match the potential hit
640 	 * "Smith, Fred" and also "Frédéric".  Searching for "Fréd" would match
641 	 * "Frédéric" but not "Frederic" (due to the one-directional nature of
642 	 * accent matching).  Searching "fo" would match "Foo" and "Bar Foo
643 	 * Baz", but not "SFO" (because no word as "fo" as a prefix).
644 	 *
645 	 * Params:
646 	 *     searchTerm = the search term from the user
647 	 *     potentialHit = the text that may be a hit
648 	 *     acceptAlternates = %TRUE to accept ASCII alternates
649 	 *
650 	 * Return: %TRUE if @potential_hit is a hit
651 	 *
652 	 * Since: 2.40
653 	 */
654 	public static bool matchString(string searchTerm, string potentialHit, bool acceptAlternates)
655 	{
656 		return g_str_match_string(Str.toStringz(searchTerm), Str.toStringz(potentialHit), acceptAlternates) != 0;
657 	}
658 
659 	/**
660 	 * Transliterate @str to plain ASCII.
661 	 *
662 	 * For best results, @str should be in composed normalised form.
663 	 *
664 	 * This function performs a reasonably good set of character
665 	 * replacements.  The particular set of replacements that is done may
666 	 * change by version or even by runtime environment.
667 	 *
668 	 * If the source language of @str is known, it can used to improve the
669 	 * accuracy of the translation by passing it as @from_locale.  It should
670 	 * be a valid POSIX locale string (of the form
671 	 * "language[_territory][.codeset][@modifier]").
672 	 *
673 	 * If @from_locale is %NULL then the current locale is used.
674 	 *
675 	 * If you want to do translation for no specific locale, and you want it
676 	 * to be done independently of the currently locale, specify "C" for
677 	 * @from_locale.
678 	 *
679 	 * Params:
680 	 *     str = a string, in UTF-8
681 	 *     fromLocale = the source locale, if known
682 	 *
683 	 * Return: a string in plain ASCII
684 	 */
685 	public static string toAscii(string str, string fromLocale)
686 	{
687 		auto retStr = g_str_to_ascii(Str.toStringz(str), Str.toStringz(fromLocale));
688 		
689 		scope(exit) Str.freeString(retStr);
690 		return Str.toString(retStr);
691 	}
692 
693 	/**
694 	 * Tokenises @string and performs folding on each token.
695 	 *
696 	 * A token is a non-empty sequence of alphanumeric characters in the
697 	 * source string, separated by non-alphanumeric characters.  An
698 	 * "alphanumeric" character for this purpose is one that matches
699 	 * g_unichar_isalnum() or g_unichar_ismark().
700 	 *
701 	 * Each token is then (Unicode) normalised and case-folded.  If
702 	 * @ascii_alternates is non-%NULL and some of the returned tokens
703 	 * contain non-ASCII characters, ASCII alternatives will be generated.
704 	 *
705 	 * The number of ASCII alternatives that are generated and the method
706 	 * for doing so is unspecified, but @translit_locale (if specified) may
707 	 * improve the transliteration if the language of the source string is
708 	 * known.
709 	 *
710 	 * Params:
711 	 *     str = a string
712 	 *     translitLocale = the language code (like 'de' or
713 	 *         'en_GB') from which @string originates
714 	 *     asciiAlternates = a
715 	 *         return location for ASCII alternates
716 	 *
717 	 * Return: the folded tokens
718 	 *
719 	 * Since: 2.40
720 	 */
721 	public static string[] tokenizeAndFold(string str, string translitLocale, out string[] asciiAlternates)
722 	{
723 		char** outasciiAlternates = null;
724 		
725 		auto retStr = g_str_tokenize_and_fold(Str.toStringz(str), Str.toStringz(translitLocale), &outasciiAlternates);
726 		
727 		asciiAlternates = Str.toStringArray(outasciiAlternates);
728 		
729 		scope(exit) Str.freeStringArray(retStr);
730 		return Str.toStringArray(retStr);
731 	}
732 
733 	/**
734 	 * For each character in @string, if the character is not in @valid_chars,
735 	 * replaces the character with @substitutor. Modifies @string in place,
736 	 * and return @string itself, not a copy. The return value is to allow
737 	 * nesting such as
738 	 * |[<!-- language="C" -->
739 	 * g_ascii_strup (g_strcanon (str, "abc", '?'))
740 	 * ]|
741 	 *
742 	 * Params:
743 	 *     str = a nul-terminated array of bytes
744 	 *     validChars = bytes permitted in @string
745 	 *     substitutor = replacement character for disallowed bytes
746 	 *
747 	 * Return: @string
748 	 */
749 	public static string strcanon(string str, string validChars, char substitutor)
750 	{
751 		auto retStr = g_strcanon(Str.toStringz(str), Str.toStringz(validChars), substitutor);
752 		
753 		scope(exit) Str.freeString(retStr);
754 		return Str.toString(retStr);
755 	}
756 
757 	/**
758 	 * A case-insensitive string comparison, corresponding to the standard
759 	 * strcasecmp() function on platforms which support it.
760 	 *
761 	 * Deprecated: See g_strncasecmp() for a discussion of why this
762 	 * function is deprecated and how to replace it.
763 	 *
764 	 * Params:
765 	 *     s1 = a string
766 	 *     s2 = a string to compare with @s1
767 	 *
768 	 * Return: 0 if the strings match, a negative value if @s1 < @s2,
769 	 *     or a positive value if @s1 > @s2.
770 	 */
771 	public static int strcasecmp(string s1, string s2)
772 	{
773 		return g_strcasecmp(Str.toStringz(s1), Str.toStringz(s2));
774 	}
775 
776 	/**
777 	 * Removes trailing whitespace from a string.
778 	 *
779 	 * This function doesn't allocate or reallocate any memory;
780 	 * it modifies @string in place. Therefore, it cannot be used
781 	 * on statically allocated strings.
782 	 *
783 	 * The pointer to @string is returned to allow the nesting of functions.
784 	 *
785 	 * Also see g_strchug() and g_strstrip().
786 	 *
787 	 * Params:
788 	 *     str = a string to remove the trailing whitespace from
789 	 *
790 	 * Return: @string
791 	 */
792 	public static string strchomp(string str)
793 	{
794 		auto retStr = g_strchomp(Str.toStringz(str));
795 		
796 		scope(exit) Str.freeString(retStr);
797 		return Str.toString(retStr);
798 	}
799 
800 	/**
801 	 * Removes leading whitespace from a string, by moving the rest
802 	 * of the characters forward.
803 	 *
804 	 * This function doesn't allocate or reallocate any memory;
805 	 * it modifies @string in place. Therefore, it cannot be used on
806 	 * statically allocated strings.
807 	 *
808 	 * The pointer to @string is returned to allow the nesting of functions.
809 	 *
810 	 * Also see g_strchomp() and g_strstrip().
811 	 *
812 	 * Params:
813 	 *     str = a string to remove the leading whitespace from
814 	 *
815 	 * Return: @string
816 	 */
817 	public static string strchug(string str)
818 	{
819 		auto retStr = g_strchug(Str.toStringz(str));
820 		
821 		scope(exit) Str.freeString(retStr);
822 		return Str.toString(retStr);
823 	}
824 
825 	/**
826 	 * Compares @str1 and @str2 like strcmp(). Handles %NULL
827 	 * gracefully by sorting it before non-%NULL strings.
828 	 * Comparing two %NULL pointers returns 0.
829 	 *
830 	 * Params:
831 	 *     str1 = a C string or %NULL
832 	 *     str2 = another C string or %NULL
833 	 *
834 	 * Return: an integer less than, equal to, or greater than zero, if @str1 is <, == or > than @str2.
835 	 *
836 	 * Since: 2.16
837 	 */
838 	public static int strcmp0(string str1, string str2)
839 	{
840 		return g_strcmp0(Str.toStringz(str1), Str.toStringz(str2));
841 	}
842 
843 	/**
844 	 * Replaces all escaped characters with their one byte equivalent.
845 	 *
846 	 * This function does the reverse conversion of g_strescape().
847 	 *
848 	 * Params:
849 	 *     source = a string to compress
850 	 *
851 	 * Return: a newly-allocated copy of @source with all escaped
852 	 *     character compressed
853 	 */
854 	public static string strcompress(string source)
855 	{
856 		auto retStr = g_strcompress(Str.toStringz(source));
857 		
858 		scope(exit) Str.freeString(retStr);
859 		return Str.toString(retStr);
860 	}
861 
862 	/**
863 	 * Converts any delimiter characters in @string to @new_delimiter.
864 	 * Any characters in @string which are found in @delimiters are
865 	 * changed to the @new_delimiter character. Modifies @string in place,
866 	 * and returns @string itself, not a copy. The return value is to
867 	 * allow nesting such as
868 	 * |[<!-- language="C" -->
869 	 * g_ascii_strup (g_strdelimit (str, "abc", '?'))
870 	 * ]|
871 	 *
872 	 * Params:
873 	 *     str = the string to convert
874 	 *     delimiters = a string containing the current delimiters,
875 	 *         or %NULL to use the standard delimiters defined in #G_STR_DELIMITERS
876 	 *     newDelimiter = the new delimiter character
877 	 *
878 	 * Return: @string
879 	 */
880 	public static string strdelimit(string str, string delimiters, char newDelimiter)
881 	{
882 		auto retStr = g_strdelimit(Str.toStringz(str), Str.toStringz(delimiters), newDelimiter);
883 		
884 		scope(exit) Str.freeString(retStr);
885 		return Str.toString(retStr);
886 	}
887 
888 	/**
889 	 * Converts a string to lower case.
890 	 *
891 	 * Deprecated: This function is totally broken for the reasons discussed
892 	 * in the g_strncasecmp() docs - use g_ascii_strdown() or g_utf8_strdown()
893 	 * instead.
894 	 *
895 	 * Params:
896 	 *     str = the string to convert.
897 	 *
898 	 * Return: the string
899 	 */
900 	public static string strdown(string str)
901 	{
902 		auto retStr = g_strdown(Str.toStringz(str));
903 		
904 		scope(exit) Str.freeString(retStr);
905 		return Str.toString(retStr);
906 	}
907 
908 	/**
909 	 * Duplicates a string. If @str is %NULL it returns %NULL.
910 	 * The returned string should be freed with g_free()
911 	 * when no longer needed.
912 	 *
913 	 * Params:
914 	 *     str = the string to duplicate
915 	 *
916 	 * Return: a newly-allocated copy of @str
917 	 */
918 	public static string strdup(string str)
919 	{
920 		auto retStr = g_strdup(Str.toStringz(str));
921 		
922 		scope(exit) Str.freeString(retStr);
923 		return Str.toString(retStr);
924 	}
925 
926 	/**
927 	 * Similar to the standard C vsprintf() function but safer, since it
928 	 * calculates the maximum space required and allocates memory to hold
929 	 * the result. The returned string should be freed with g_free() when
930 	 * no longer needed.
931 	 *
932 	 * See also g_vasprintf(), which offers the same functionality, but
933 	 * additionally returns the length of the allocated string.
934 	 *
935 	 * Params:
936 	 *     format = a standard printf() format string, but notice
937 	 *         [string precision pitfalls][string-precision]
938 	 *     args = the list of parameters to insert into the format string
939 	 *
940 	 * Return: a newly-allocated string holding the result
941 	 */
942 	public static string strdupVprintf(string format, void* args)
943 	{
944 		auto retStr = g_strdup_vprintf(Str.toStringz(format), args);
945 		
946 		scope(exit) Str.freeString(retStr);
947 		return Str.toString(retStr);
948 	}
949 
950 	/**
951 	 * Copies %NULL-terminated array of strings. The copy is a deep copy;
952 	 * the new array should be freed by first freeing each string, then
953 	 * the array itself. g_strfreev() does this for you. If called
954 	 * on a %NULL value, g_strdupv() simply returns %NULL.
955 	 *
956 	 * Params:
957 	 *     strArray = a %NULL-terminated array of strings
958 	 *
959 	 * Return: a new %NULL-terminated array of strings.
960 	 */
961 	public static string[] strdupv(string[] strArray)
962 	{
963 		return Str.toStringArray(g_strdupv(Str.toStringzArray(strArray)));
964 	}
965 
966 	/**
967 	 * Returns a string corresponding to the given error code, e.g. "no
968 	 * such process". Unlike strerror(), this always returns a string in
969 	 * UTF-8 encoding, and the pointer is guaranteed to remain valid for
970 	 * the lifetime of the process.
971 	 *
972 	 * Note that the string may be translated according to the current locale.
973 	 *
974 	 * The value of %errno will not be changed by this function.
975 	 *
976 	 * Params:
977 	 *     errnum = the system error number. See the standard C %errno
978 	 *         documentation
979 	 *
980 	 * Return: a UTF-8 string describing the error code. If the error code
981 	 *     is unknown, it returns a string like "unknown error (<code>)".
982 	 */
983 	public static string strerror(int errnum)
984 	{
985 		return Str.toString(g_strerror(errnum));
986 	}
987 
988 	/**
989 	 * Escapes the special characters '\b', '\f', '\n', '\r', '\t', '\v', '\'
990 	 * and '&quot;' in the string @source by inserting a '\' before
991 	 * them. Additionally all characters in the range 0x01-0x1F (everything
992 	 * below SPACE) and in the range 0x7F-0xFF (all non-ASCII chars) are
993 	 * replaced with a '\' followed by their octal representation.
994 	 * Characters supplied in @exceptions are not escaped.
995 	 *
996 	 * g_strcompress() does the reverse conversion.
997 	 *
998 	 * Params:
999 	 *     source = a string to escape
1000 	 *     exceptions = a string of characters not to escape in @source
1001 	 *
1002 	 * Return: a newly-allocated copy of @source with certain
1003 	 *     characters escaped. See above.
1004 	 */
1005 	public static string strescape(string source, string exceptions)
1006 	{
1007 		auto retStr = g_strescape(Str.toStringz(source), Str.toStringz(exceptions));
1008 		
1009 		scope(exit) Str.freeString(retStr);
1010 		return Str.toString(retStr);
1011 	}
1012 
1013 	/**
1014 	 * Frees a %NULL-terminated array of strings, as well as each
1015 	 * string it contains.
1016 	 *
1017 	 * If @str_array is %NULL, this function simply returns.
1018 	 *
1019 	 * Params:
1020 	 *     strArray = a %NULL-terminated array of strings to free
1021 	 */
1022 	public static void strfreev(string[] strArray)
1023 	{
1024 		g_strfreev(Str.toStringzArray(strArray));
1025 	}
1026 
1027 	/**
1028 	 * Joins a number of strings together to form one long string, with the
1029 	 * optional @separator inserted between each of them. The returned string
1030 	 * should be freed with g_free().
1031 	 *
1032 	 * Params:
1033 	 *     separator = a string to insert between each of the
1034 	 *         strings, or %NULL
1035 	 *     strArray = a %NULL-terminated array of strings to join
1036 	 *
1037 	 * Return: a newly-allocated string containing all of the strings joined
1038 	 *     together, with @separator between them
1039 	 */
1040 	public static string strjoinv(string separator, string[] strArray)
1041 	{
1042 		auto retStr = g_strjoinv(Str.toStringz(separator), Str.toStringzArray(strArray));
1043 		
1044 		scope(exit) Str.freeString(retStr);
1045 		return Str.toString(retStr);
1046 	}
1047 
1048 	/**
1049 	 * Portability wrapper that calls strlcat() on systems which have it,
1050 	 * and emulates it otherwise. Appends nul-terminated @src string to @dest,
1051 	 * guaranteeing nul-termination for @dest. The total size of @dest won't
1052 	 * exceed @dest_size.
1053 	 *
1054 	 * At most @dest_size - 1 characters will be copied. Unlike strncat(),
1055 	 * @dest_size is the full size of dest, not the space left over. This
1056 	 * function does not allocate memory. It always nul-terminates (unless
1057 	 * @dest_size == 0 or there were no nul characters in the @dest_size
1058 	 * characters of dest to start with).
1059 	 *
1060 	 * Caveat: this is supposedly a more secure alternative to strcat() or
1061 	 * strncat(), but for real security g_strconcat() is harder to mess up.
1062 	 *
1063 	 * Params:
1064 	 *     dest = destination buffer, already containing one nul-terminated string
1065 	 *     src = source buffer
1066 	 *     destSize = length of @dest buffer in bytes (not length of existing string
1067 	 *         inside @dest)
1068 	 *
1069 	 * Return: size of attempted result, which is MIN (dest_size, strlen
1070 	 *     (original dest)) + strlen (src), so if retval >= dest_size,
1071 	 *     truncation occurred.
1072 	 */
1073 	public static size_t strlcat(string dest, string src, size_t destSize)
1074 	{
1075 		return g_strlcat(Str.toStringz(dest), Str.toStringz(src), destSize);
1076 	}
1077 
1078 	/**
1079 	 * Portability wrapper that calls strlcpy() on systems which have it,
1080 	 * and emulates strlcpy() otherwise. Copies @src to @dest; @dest is
1081 	 * guaranteed to be nul-terminated; @src must be nul-terminated;
1082 	 * @dest_size is the buffer size, not the number of bytes to copy.
1083 	 *
1084 	 * At most @dest_size - 1 characters will be copied. Always nul-terminates
1085 	 * (unless @dest_size is 0). This function does not allocate memory. Unlike
1086 	 * strncpy(), this function doesn't pad @dest (so it's often faster). It
1087 	 * returns the size of the attempted result, strlen (src), so if
1088 	 * @retval >= @dest_size, truncation occurred.
1089 	 *
1090 	 * Caveat: strlcpy() is supposedly more secure than strcpy() or strncpy(),
1091 	 * but if you really want to avoid screwups, g_strdup() is an even better
1092 	 * idea.
1093 	 *
1094 	 * Params:
1095 	 *     dest = destination buffer
1096 	 *     src = source buffer
1097 	 *     destSize = length of @dest in bytes
1098 	 *
1099 	 * Return: length of @src
1100 	 */
1101 	public static size_t strlcpy(string dest, string src, size_t destSize)
1102 	{
1103 		return g_strlcpy(Str.toStringz(dest), Str.toStringz(src), destSize);
1104 	}
1105 
1106 	/**
1107 	 * A case-insensitive string comparison, corresponding to the standard
1108 	 * strncasecmp() function on platforms which support it. It is similar
1109 	 * to g_strcasecmp() except it only compares the first @n characters of
1110 	 * the strings.
1111 	 *
1112 	 * Deprecated: The problem with g_strncasecmp() is that it does
1113 	 * the comparison by calling toupper()/tolower(). These functions
1114 	 * are locale-specific and operate on single bytes. However, it is
1115 	 * impossible to handle things correctly from an internationalization
1116 	 * standpoint by operating on bytes, since characters may be multibyte.
1117 	 * Thus g_strncasecmp() is broken if your string is guaranteed to be
1118 	 * ASCII, since it is locale-sensitive, and it's broken if your string
1119 	 * is localized, since it doesn't work on many encodings at all,
1120 	 * including UTF-8, EUC-JP, etc.
1121 	 *
1122 	 * There are therefore two replacement techniques: g_ascii_strncasecmp(),
1123 	 * which only works on ASCII and is not locale-sensitive, and
1124 	 * g_utf8_casefold() followed by strcmp() on the resulting strings,
1125 	 * which is good for case-insensitive sorting of UTF-8.
1126 	 *
1127 	 * Params:
1128 	 *     s1 = a string
1129 	 *     s2 = a string to compare with @s1
1130 	 *     n = the maximum number of characters to compare
1131 	 *
1132 	 * Return: 0 if the strings match, a negative value if @s1 < @s2,
1133 	 *     or a positive value if @s1 > @s2.
1134 	 */
1135 	public static int strncasecmp(string s1, string s2, uint n)
1136 	{
1137 		return g_strncasecmp(Str.toStringz(s1), Str.toStringz(s2), n);
1138 	}
1139 
1140 	/**
1141 	 * Duplicates the first @n bytes of a string, returning a newly-allocated
1142 	 * buffer @n + 1 bytes long which will always be nul-terminated. If @str
1143 	 * is less than @n bytes long the buffer is padded with nuls. If @str is
1144 	 * %NULL it returns %NULL. The returned value should be freed when no longer
1145 	 * needed.
1146 	 *
1147 	 * To copy a number of characters from a UTF-8 encoded string,
1148 	 * use g_utf8_strncpy() instead.
1149 	 *
1150 	 * Params:
1151 	 *     str = the string to duplicate
1152 	 *     n = the maximum number of bytes to copy from @str
1153 	 *
1154 	 * Return: a newly-allocated buffer containing the first @n bytes
1155 	 *     of @str, nul-terminated
1156 	 */
1157 	public static string strndup(string str, size_t n)
1158 	{
1159 		auto retStr = g_strndup(Str.toStringz(str), n);
1160 		
1161 		scope(exit) Str.freeString(retStr);
1162 		return Str.toString(retStr);
1163 	}
1164 
1165 	/**
1166 	 * Creates a new string @length bytes long filled with @fill_char.
1167 	 * The returned string should be freed when no longer needed.
1168 	 *
1169 	 * Params:
1170 	 *     length = the length of the new string
1171 	 *     fillChar = the byte to fill the string with
1172 	 *
1173 	 * Return: a newly-allocated string filled the @fill_char
1174 	 */
1175 	public static string strnfill(size_t length, char fillChar)
1176 	{
1177 		auto retStr = g_strnfill(length, fillChar);
1178 		
1179 		scope(exit) Str.freeString(retStr);
1180 		return Str.toString(retStr);
1181 	}
1182 
1183 	/**
1184 	 * Reverses all of the bytes in a string. For example,
1185 	 * `g_strreverse ("abcdef")` will result in "fedcba".
1186 	 *
1187 	 * Note that g_strreverse() doesn't work on UTF-8 strings
1188 	 * containing multibyte characters. For that purpose, use
1189 	 * g_utf8_strreverse().
1190 	 *
1191 	 * Params:
1192 	 *     str = the string to reverse
1193 	 *
1194 	 * Return: the same pointer passed in as @string
1195 	 */
1196 	public static string strreverse(string str)
1197 	{
1198 		auto retStr = g_strreverse(Str.toStringz(str));
1199 		
1200 		scope(exit) Str.freeString(retStr);
1201 		return Str.toString(retStr);
1202 	}
1203 
1204 	/**
1205 	 * Searches the string @haystack for the last occurrence
1206 	 * of the string @needle.
1207 	 *
1208 	 * Params:
1209 	 *     haystack = a nul-terminated string
1210 	 *     needle = the nul-terminated string to search for
1211 	 *
1212 	 * Return: a pointer to the found occurrence, or
1213 	 *     %NULL if not found.
1214 	 */
1215 	public static string strrstr(string haystack, string needle)
1216 	{
1217 		auto retStr = g_strrstr(Str.toStringz(haystack), Str.toStringz(needle));
1218 		
1219 		scope(exit) Str.freeString(retStr);
1220 		return Str.toString(retStr);
1221 	}
1222 
1223 	/**
1224 	 * Searches the string @haystack for the last occurrence
1225 	 * of the string @needle, limiting the length of the search
1226 	 * to @haystack_len.
1227 	 *
1228 	 * Params:
1229 	 *     haystack = a nul-terminated string
1230 	 *     haystackLen = the maximum length of @haystack
1231 	 *     needle = the nul-terminated string to search for
1232 	 *
1233 	 * Return: a pointer to the found occurrence, or
1234 	 *     %NULL if not found.
1235 	 */
1236 	public static string strrstrLen(string haystack, ptrdiff_t haystackLen, string needle)
1237 	{
1238 		auto retStr = g_strrstr_len(Str.toStringz(haystack), haystackLen, Str.toStringz(needle));
1239 		
1240 		scope(exit) Str.freeString(retStr);
1241 		return Str.toString(retStr);
1242 	}
1243 
1244 	/**
1245 	 * Returns a string describing the given signal, e.g. "Segmentation fault".
1246 	 * You should use this function in preference to strsignal(), because it
1247 	 * returns a string in UTF-8 encoding, and since not all platforms support
1248 	 * the strsignal() function.
1249 	 *
1250 	 * Params:
1251 	 *     signum = the signal number. See the `signal` documentation
1252 	 *
1253 	 * Return: a UTF-8 string describing the signal. If the signal is unknown,
1254 	 *     it returns "unknown signal (<signum>)".
1255 	 */
1256 	public static string strsignal(int signum)
1257 	{
1258 		return Str.toString(g_strsignal(signum));
1259 	}
1260 
1261 	/**
1262 	 * Splits a string into a maximum of @max_tokens pieces, using the given
1263 	 * @delimiter. If @max_tokens is reached, the remainder of @string is
1264 	 * appended to the last token.
1265 	 *
1266 	 * As an example, the result of g_strsplit (":a:bc::d:", ":", -1) is a
1267 	 * %NULL-terminated vector containing the six strings "", "a", "bc", "", "d"
1268 	 * and "".
1269 	 *
1270 	 * As a special case, the result of splitting the empty string "" is an empty
1271 	 * vector, not a vector containing a single string. The reason for this
1272 	 * special case is that being able to represent a empty vector is typically
1273 	 * more useful than consistent handling of empty elements. If you do need
1274 	 * to represent empty elements, you'll need to check for the empty string
1275 	 * before calling g_strsplit().
1276 	 *
1277 	 * Params:
1278 	 *     str = a string to split
1279 	 *     delimiter = a string which specifies the places at which to split
1280 	 *         the string. The delimiter is not included in any of the resulting
1281 	 *         strings, unless @max_tokens is reached.
1282 	 *     maxTokens = the maximum number of pieces to split @string into.
1283 	 *         If this is less than 1, the string is split completely.
1284 	 *
1285 	 * Return: a newly-allocated %NULL-terminated array of strings. Use
1286 	 *     g_strfreev() to free it.
1287 	 */
1288 	public static string[] strsplit(string str, string delimiter, int maxTokens)
1289 	{
1290 		return Str.toStringArray(g_strsplit(Str.toStringz(str), Str.toStringz(delimiter), maxTokens));
1291 	}
1292 
1293 	/**
1294 	 * Splits @string into a number of tokens not containing any of the characters
1295 	 * in @delimiter. A token is the (possibly empty) longest string that does not
1296 	 * contain any of the characters in @delimiters. If @max_tokens is reached, the
1297 	 * remainder is appended to the last token.
1298 	 *
1299 	 * For example the result of g_strsplit_set ("abc:def/ghi", ":/", -1) is a
1300 	 * %NULL-terminated vector containing the three strings "abc", "def",
1301 	 * and "ghi".
1302 	 *
1303 	 * The result of g_strsplit_set (":def/ghi:", ":/", -1) is a %NULL-terminated
1304 	 * vector containing the four strings "", "def", "ghi", and "".
1305 	 *
1306 	 * As a special case, the result of splitting the empty string "" is an empty
1307 	 * vector, not a vector containing a single string. The reason for this
1308 	 * special case is that being able to represent a empty vector is typically
1309 	 * more useful than consistent handling of empty elements. If you do need
1310 	 * to represent empty elements, you'll need to check for the empty string
1311 	 * before calling g_strsplit_set().
1312 	 *
1313 	 * Note that this function works on bytes not characters, so it can't be used
1314 	 * to delimit UTF-8 strings for anything but ASCII characters.
1315 	 *
1316 	 * Params:
1317 	 *     str = The string to be tokenized
1318 	 *     delimiters = A nul-terminated string containing bytes that are used
1319 	 *         to split the string.
1320 	 *     maxTokens = The maximum number of tokens to split @string into.
1321 	 *         If this is less than 1, the string is split completely
1322 	 *
1323 	 * Return: a newly-allocated %NULL-terminated array of strings. Use
1324 	 *     g_strfreev() to free it.
1325 	 *
1326 	 * Since: 2.4
1327 	 */
1328 	public static string[] strsplitSet(string str, string delimiters, int maxTokens)
1329 	{
1330 		return Str.toStringArray(g_strsplit_set(Str.toStringz(str), Str.toStringz(delimiters), maxTokens));
1331 	}
1332 
1333 	/**
1334 	 * Searches the string @haystack for the first occurrence
1335 	 * of the string @needle, limiting the length of the search
1336 	 * to @haystack_len.
1337 	 *
1338 	 * Params:
1339 	 *     haystack = a string
1340 	 *     haystackLen = the maximum length of @haystack. Note that -1 is
1341 	 *         a valid length, if @haystack is nul-terminated, meaning it will
1342 	 *         search through the whole string.
1343 	 *     needle = the string to search for
1344 	 *
1345 	 * Return: a pointer to the found occurrence, or
1346 	 *     %NULL if not found.
1347 	 */
1348 	public static string strstrLen(string haystack, ptrdiff_t haystackLen, string needle)
1349 	{
1350 		auto retStr = g_strstr_len(Str.toStringz(haystack), haystackLen, Str.toStringz(needle));
1351 		
1352 		scope(exit) Str.freeString(retStr);
1353 		return Str.toString(retStr);
1354 	}
1355 
1356 	/**
1357 	 * Converts a string to a #gdouble value.
1358 	 * It calls the standard strtod() function to handle the conversion, but
1359 	 * if the string is not completely converted it attempts the conversion
1360 	 * again with g_ascii_strtod(), and returns the best match.
1361 	 *
1362 	 * This function should seldom be used. The normal situation when reading
1363 	 * numbers not for human consumption is to use g_ascii_strtod(). Only when
1364 	 * you know that you must expect both locale formatted and C formatted numbers
1365 	 * should you use this. Make sure that you don't pass strings such as comma
1366 	 * separated lists of values, since the commas may be interpreted as a decimal
1367 	 * point in some locales, causing unexpected results.
1368 	 *
1369 	 * Params:
1370 	 *     nptr = the string to convert to a numeric value.
1371 	 *     endptr = if non-%NULL, it returns the
1372 	 *         character after the last character used in the conversion.
1373 	 *
1374 	 * Return: the #gdouble value.
1375 	 */
1376 	public static double strtod(string nptr, out string endptr)
1377 	{
1378 		char* outendptr = null;
1379 		
1380 		auto p = g_strtod(Str.toStringz(nptr), &outendptr);
1381 		
1382 		endptr = Str.toString(outendptr);
1383 		
1384 		return p;
1385 	}
1386 
1387 	/**
1388 	 * Converts a string to upper case.
1389 	 *
1390 	 * Deprecated: This function is totally broken for the reasons
1391 	 * discussed in the g_strncasecmp() docs - use g_ascii_strup()
1392 	 * or g_utf8_strup() instead.
1393 	 *
1394 	 * Params:
1395 	 *     str = the string to convert
1396 	 *
1397 	 * Return: the string
1398 	 */
1399 	public static string strup(string str)
1400 	{
1401 		auto retStr = g_strup(Str.toStringz(str));
1402 		
1403 		scope(exit) Str.freeString(retStr);
1404 		return Str.toString(retStr);
1405 	}
1406 
1407 	/** */
1408 	public static GType strvGetType()
1409 	{
1410 		return g_strv_get_type();
1411 	}
1412 
1413 	/**
1414 	 * Returns the length of the given %NULL-terminated
1415 	 * string array @str_array.
1416 	 *
1417 	 * Params:
1418 	 *     strArray = a %NULL-terminated array of strings
1419 	 *
1420 	 * Return: length of @str_array.
1421 	 *
1422 	 * Since: 2.6
1423 	 */
1424 	public static uint strvLength(string[] strArray)
1425 	{
1426 		return g_strv_length(Str.toStringzArray(strArray));
1427 	}
1428 
1429 	/**
1430 	 * Checks if @strv contains @str. @strv must not be %NULL.
1431 	 *
1432 	 * Params:
1433 	 *     strv = a %NULL-terminated array of strings
1434 	 *     str = a string
1435 	 *
1436 	 * Return: %TRUE if @str is an element of @strv, according to g_str_equal().
1437 	 *
1438 	 * Since: 2.44
1439 	 */
1440 	public static bool strvContains(string strv, string str)
1441 	{
1442 		return g_strv_contains(Str.toStringz(strv), Str.toStringz(str)) != 0;
1443 	}
1444 
1445 	/**
1446 	 * An implementation of the GNU vasprintf() function which supports
1447 	 * positional parameters, as specified in the Single Unix Specification.
1448 	 * This function is similar to g_vsprintf(), except that it allocates a
1449 	 * string to hold the output, instead of putting the output in a buffer
1450 	 * you allocate in advance.
1451 	 *
1452 	 * Params:
1453 	 *     str = the return location for the newly-allocated string.
1454 	 *     format = a standard printf() format string, but notice
1455 	 *         [string precision pitfalls][string-precision]
1456 	 *     args = the list of arguments to insert in the output.
1457 	 *
1458 	 * Return: the number of bytes printed.
1459 	 *
1460 	 * Since: 2.4
1461 	 */
1462 	public static int vasprintf(string[] str, string format, void* args)
1463 	{
1464 		return g_vasprintf(Str.toStringzArray(str), Str.toStringz(format), args);
1465 	}
1466 
1467 	/**
1468 	 * An implementation of the standard fprintf() function which supports
1469 	 * positional parameters, as specified in the Single Unix Specification.
1470 	 *
1471 	 * Params:
1472 	 *     file = the stream to write to.
1473 	 *     format = a standard printf() format string, but notice
1474 	 *         [string precision pitfalls][string-precision]
1475 	 *     args = the list of arguments to insert in the output.
1476 	 *
1477 	 * Return: the number of bytes printed.
1478 	 *
1479 	 * Since: 2.2
1480 	 */
1481 	public static int vfprintf(FILE* file, string format, void* args)
1482 	{
1483 		return g_vfprintf(file, Str.toStringz(format), args);
1484 	}
1485 
1486 	/**
1487 	 * An implementation of the standard vprintf() function which supports
1488 	 * positional parameters, as specified in the Single Unix Specification.
1489 	 *
1490 	 * Params:
1491 	 *     format = a standard printf() format string, but notice
1492 	 *         [string precision pitfalls][string-precision]
1493 	 *     args = the list of arguments to insert in the output.
1494 	 *
1495 	 * Return: the number of bytes printed.
1496 	 *
1497 	 * Since: 2.2
1498 	 */
1499 	public static int vprintf(string format, void* args)
1500 	{
1501 		return g_vprintf(Str.toStringz(format), args);
1502 	}
1503 
1504 	/**
1505 	 * A safer form of the standard vsprintf() function. The output is guaranteed
1506 	 * to not exceed @n characters (including the terminating nul character), so
1507 	 * it is easy to ensure that a buffer overflow cannot occur.
1508 	 *
1509 	 * See also g_strdup_vprintf().
1510 	 *
1511 	 * In versions of GLib prior to 1.2.3, this function may return -1 if the
1512 	 * output was truncated, and the truncated string may not be nul-terminated.
1513 	 * In versions prior to 1.3.12, this function returns the length of the output
1514 	 * string.
1515 	 *
1516 	 * The return value of g_vsnprintf() conforms to the vsnprintf() function
1517 	 * as standardized in ISO C99. Note that this is different from traditional
1518 	 * vsnprintf(), which returns the length of the output string.
1519 	 *
1520 	 * The format string may contain positional parameters, as specified in
1521 	 * the Single Unix Specification.
1522 	 *
1523 	 * Params:
1524 	 *     str = the buffer to hold the output.
1525 	 *     n = the maximum number of bytes to produce (including the
1526 	 *         terminating nul character).
1527 	 *     format = a standard printf() format string, but notice
1528 	 *         string precision pitfalls][string-precision]
1529 	 *     args = the list of arguments to insert in the output.
1530 	 *
1531 	 * Return: the number of bytes which would be produced if the buffer
1532 	 *     was large enough.
1533 	 */
1534 	public static int vsnprintf(string str, gulong n, string format, void* args)
1535 	{
1536 		return g_vsnprintf(Str.toStringz(str), n, Str.toStringz(format), args);
1537 	}
1538 
1539 	/**
1540 	 * An implementation of the standard vsprintf() function which supports
1541 	 * positional parameters, as specified in the Single Unix Specification.
1542 	 *
1543 	 * Params:
1544 	 *     str = the buffer to hold the output.
1545 	 *     format = a standard printf() format string, but notice
1546 	 *         [string precision pitfalls][string-precision]
1547 	 *     args = the list of arguments to insert in the output.
1548 	 *
1549 	 * Return: the number of bytes printed.
1550 	 *
1551 	 * Since: 2.2
1552 	 */
1553 	public static int vsprintf(string str, string format, void* args)
1554 	{
1555 		return g_vsprintf(Str.toStringz(str), Str.toStringz(format), args);
1556 	}
1557 }