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