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 	 * Since: 2.40
686 	 */
687 	public static string toAscii(string str, string fromLocale)
688 	{
689 		auto retStr = g_str_to_ascii(Str.toStringz(str), Str.toStringz(fromLocale));
690 		
691 		scope(exit) Str.freeString(retStr);
692 		return Str.toString(retStr);
693 	}
694 
695 	/**
696 	 * Tokenises @string and performs folding on each token.
697 	 *
698 	 * A token is a non-empty sequence of alphanumeric characters in the
699 	 * source string, separated by non-alphanumeric characters.  An
700 	 * "alphanumeric" character for this purpose is one that matches
701 	 * g_unichar_isalnum() or g_unichar_ismark().
702 	 *
703 	 * Each token is then (Unicode) normalised and case-folded.  If
704 	 * @ascii_alternates is non-%NULL and some of the returned tokens
705 	 * contain non-ASCII characters, ASCII alternatives will be generated.
706 	 *
707 	 * The number of ASCII alternatives that are generated and the method
708 	 * for doing so is unspecified, but @translit_locale (if specified) may
709 	 * improve the transliteration if the language of the source string is
710 	 * known.
711 	 *
712 	 * Params:
713 	 *     str = a string
714 	 *     translitLocale = the language code (like 'de' or
715 	 *         'en_GB') from which @string originates
716 	 *     asciiAlternates = a
717 	 *         return location for ASCII alternates
718 	 *
719 	 * Return: the folded tokens
720 	 *
721 	 * Since: 2.40
722 	 */
723 	public static string[] tokenizeAndFold(string str, string translitLocale, out string[] asciiAlternates)
724 	{
725 		char** outasciiAlternates = null;
726 		
727 		auto retStr = g_str_tokenize_and_fold(Str.toStringz(str), Str.toStringz(translitLocale), &outasciiAlternates);
728 		
729 		asciiAlternates = Str.toStringArray(outasciiAlternates);
730 		
731 		scope(exit) Str.freeStringArray(retStr);
732 		return Str.toStringArray(retStr);
733 	}
734 
735 	/**
736 	 * For each character in @string, if the character is not in @valid_chars,
737 	 * replaces the character with @substitutor. Modifies @string in place,
738 	 * and return @string itself, not a copy. The return value is to allow
739 	 * nesting such as
740 	 * |[<!-- language="C" -->
741 	 * g_ascii_strup (g_strcanon (str, "abc", '?'))
742 	 * ]|
743 	 *
744 	 * Params:
745 	 *     str = a nul-terminated array of bytes
746 	 *     validChars = bytes permitted in @string
747 	 *     substitutor = replacement character for disallowed bytes
748 	 *
749 	 * Return: @string
750 	 */
751 	public static string strcanon(string str, string validChars, char substitutor)
752 	{
753 		auto retStr = g_strcanon(Str.toStringz(str), Str.toStringz(validChars), substitutor);
754 		
755 		scope(exit) Str.freeString(retStr);
756 		return Str.toString(retStr);
757 	}
758 
759 	/**
760 	 * A case-insensitive string comparison, corresponding to the standard
761 	 * strcasecmp() function on platforms which support it.
762 	 *
763 	 * Deprecated: See g_strncasecmp() for a discussion of why this
764 	 * function is deprecated and how to replace it.
765 	 *
766 	 * Params:
767 	 *     s1 = a string
768 	 *     s2 = a string to compare with @s1
769 	 *
770 	 * Return: 0 if the strings match, a negative value if @s1 < @s2,
771 	 *     or a positive value if @s1 > @s2.
772 	 */
773 	public static int strcasecmp(string s1, string s2)
774 	{
775 		return g_strcasecmp(Str.toStringz(s1), Str.toStringz(s2));
776 	}
777 
778 	/**
779 	 * Removes trailing whitespace from a string.
780 	 *
781 	 * This function doesn't allocate or reallocate any memory;
782 	 * it modifies @string in place. Therefore, it cannot be used
783 	 * on statically allocated strings.
784 	 *
785 	 * The pointer to @string is returned to allow the nesting of functions.
786 	 *
787 	 * Also see g_strchug() and g_strstrip().
788 	 *
789 	 * Params:
790 	 *     str = a string to remove the trailing whitespace from
791 	 *
792 	 * Return: @string
793 	 */
794 	public static string strchomp(string str)
795 	{
796 		auto retStr = g_strchomp(Str.toStringz(str));
797 		
798 		scope(exit) Str.freeString(retStr);
799 		return Str.toString(retStr);
800 	}
801 
802 	/**
803 	 * Removes leading whitespace from a string, by moving the rest
804 	 * of the characters forward.
805 	 *
806 	 * This function doesn't allocate or reallocate any memory;
807 	 * it modifies @string in place. Therefore, it cannot be used on
808 	 * statically allocated strings.
809 	 *
810 	 * The pointer to @string is returned to allow the nesting of functions.
811 	 *
812 	 * Also see g_strchomp() and g_strstrip().
813 	 *
814 	 * Params:
815 	 *     str = a string to remove the leading whitespace from
816 	 *
817 	 * Return: @string
818 	 */
819 	public static string strchug(string str)
820 	{
821 		auto retStr = g_strchug(Str.toStringz(str));
822 		
823 		scope(exit) Str.freeString(retStr);
824 		return Str.toString(retStr);
825 	}
826 
827 	/**
828 	 * Compares @str1 and @str2 like strcmp(). Handles %NULL
829 	 * gracefully by sorting it before non-%NULL strings.
830 	 * Comparing two %NULL pointers returns 0.
831 	 *
832 	 * Params:
833 	 *     str1 = a C string or %NULL
834 	 *     str2 = another C string or %NULL
835 	 *
836 	 * Return: an integer less than, equal to, or greater than zero, if @str1 is <, == or > than @str2.
837 	 *
838 	 * Since: 2.16
839 	 */
840 	public static int strcmp0(string str1, string str2)
841 	{
842 		return g_strcmp0(Str.toStringz(str1), Str.toStringz(str2));
843 	}
844 
845 	/**
846 	 * Replaces all escaped characters with their one byte equivalent.
847 	 *
848 	 * This function does the reverse conversion of g_strescape().
849 	 *
850 	 * Params:
851 	 *     source = a string to compress
852 	 *
853 	 * Return: a newly-allocated copy of @source with all escaped
854 	 *     character compressed
855 	 */
856 	public static string strcompress(string source)
857 	{
858 		auto retStr = g_strcompress(Str.toStringz(source));
859 		
860 		scope(exit) Str.freeString(retStr);
861 		return Str.toString(retStr);
862 	}
863 
864 	/**
865 	 * Converts any delimiter characters in @string to @new_delimiter.
866 	 * Any characters in @string which are found in @delimiters are
867 	 * changed to the @new_delimiter character. Modifies @string in place,
868 	 * and returns @string itself, not a copy. The return value is to
869 	 * allow nesting such as
870 	 * |[<!-- language="C" -->
871 	 * g_ascii_strup (g_strdelimit (str, "abc", '?'))
872 	 * ]|
873 	 *
874 	 * Params:
875 	 *     str = the string to convert
876 	 *     delimiters = a string containing the current delimiters,
877 	 *         or %NULL to use the standard delimiters defined in #G_STR_DELIMITERS
878 	 *     newDelimiter = the new delimiter character
879 	 *
880 	 * Return: @string
881 	 */
882 	public static string strdelimit(string str, string delimiters, char newDelimiter)
883 	{
884 		auto retStr = g_strdelimit(Str.toStringz(str), Str.toStringz(delimiters), newDelimiter);
885 		
886 		scope(exit) Str.freeString(retStr);
887 		return Str.toString(retStr);
888 	}
889 
890 	/**
891 	 * Converts a string to lower case.
892 	 *
893 	 * Deprecated: This function is totally broken for the reasons discussed
894 	 * in the g_strncasecmp() docs - use g_ascii_strdown() or g_utf8_strdown()
895 	 * instead.
896 	 *
897 	 * Params:
898 	 *     str = the string to convert.
899 	 *
900 	 * Return: the string
901 	 */
902 	public static string strdown(string str)
903 	{
904 		auto retStr = g_strdown(Str.toStringz(str));
905 		
906 		scope(exit) Str.freeString(retStr);
907 		return Str.toString(retStr);
908 	}
909 
910 	/**
911 	 * Duplicates a string. If @str is %NULL it returns %NULL.
912 	 * The returned string should be freed with g_free()
913 	 * when no longer needed.
914 	 *
915 	 * Params:
916 	 *     str = the string to duplicate
917 	 *
918 	 * Return: a newly-allocated copy of @str
919 	 */
920 	public static string strdup(string str)
921 	{
922 		auto retStr = g_strdup(Str.toStringz(str));
923 		
924 		scope(exit) Str.freeString(retStr);
925 		return Str.toString(retStr);
926 	}
927 
928 	/**
929 	 * Similar to the standard C vsprintf() function but safer, since it
930 	 * calculates the maximum space required and allocates memory to hold
931 	 * the result. The returned string should be freed with g_free() when
932 	 * no longer needed.
933 	 *
934 	 * See also g_vasprintf(), which offers the same functionality, but
935 	 * additionally returns the length of the allocated string.
936 	 *
937 	 * Params:
938 	 *     format = a standard printf() format string, but notice
939 	 *         [string precision pitfalls][string-precision]
940 	 *     args = the list of parameters to insert into the format string
941 	 *
942 	 * Return: a newly-allocated string holding the result
943 	 */
944 	public static string strdupVprintf(string format, void* args)
945 	{
946 		auto retStr = g_strdup_vprintf(Str.toStringz(format), args);
947 		
948 		scope(exit) Str.freeString(retStr);
949 		return Str.toString(retStr);
950 	}
951 
952 	/**
953 	 * Copies %NULL-terminated array of strings. The copy is a deep copy;
954 	 * the new array should be freed by first freeing each string, then
955 	 * the array itself. g_strfreev() does this for you. If called
956 	 * on a %NULL value, g_strdupv() simply returns %NULL.
957 	 *
958 	 * Params:
959 	 *     strArray = a %NULL-terminated array of strings
960 	 *
961 	 * Return: a new %NULL-terminated array of strings.
962 	 */
963 	public static string[] strdupv(string[] strArray)
964 	{
965 		return Str.toStringArray(g_strdupv(Str.toStringzArray(strArray)));
966 	}
967 
968 	/**
969 	 * Returns a string corresponding to the given error code, e.g. "no
970 	 * such process". Unlike strerror(), this always returns a string in
971 	 * UTF-8 encoding, and the pointer is guaranteed to remain valid for
972 	 * the lifetime of the process.
973 	 *
974 	 * Note that the string may be translated according to the current locale.
975 	 *
976 	 * The value of %errno will not be changed by this function.
977 	 *
978 	 * Params:
979 	 *     errnum = the system error number. See the standard C %errno
980 	 *         documentation
981 	 *
982 	 * Return: a UTF-8 string describing the error code. If the error code
983 	 *     is unknown, it returns a string like "unknown error (<code>)".
984 	 */
985 	public static string strerror(int errnum)
986 	{
987 		return Str.toString(g_strerror(errnum));
988 	}
989 
990 	/**
991 	 * Escapes the special characters '\b', '\f', '\n', '\r', '\t', '\v', '\'
992 	 * and '"' in the string @source by inserting a '\' before
993 	 * them. Additionally all characters in the range 0x01-0x1F (everything
994 	 * below SPACE) and in the range 0x7F-0xFF (all non-ASCII chars) are
995 	 * replaced with a '\' followed by their octal representation.
996 	 * Characters supplied in @exceptions are not escaped.
997 	 *
998 	 * g_strcompress() does the reverse conversion.
999 	 *
1000 	 * Params:
1001 	 *     source = a string to escape
1002 	 *     exceptions = a string of characters not to escape in @source
1003 	 *
1004 	 * Return: a newly-allocated copy of @source with certain
1005 	 *     characters escaped. See above.
1006 	 */
1007 	public static string strescape(string source, string exceptions)
1008 	{
1009 		auto retStr = g_strescape(Str.toStringz(source), Str.toStringz(exceptions));
1010 		
1011 		scope(exit) Str.freeString(retStr);
1012 		return Str.toString(retStr);
1013 	}
1014 
1015 	/**
1016 	 * Frees a %NULL-terminated array of strings, as well as each
1017 	 * string it contains.
1018 	 *
1019 	 * If @str_array is %NULL, this function simply returns.
1020 	 *
1021 	 * Params:
1022 	 *     strArray = a %NULL-terminated array of strings to free
1023 	 */
1024 	public static void strfreev(string[] strArray)
1025 	{
1026 		g_strfreev(Str.toStringzArray(strArray));
1027 	}
1028 
1029 	/**
1030 	 * Joins a number of strings together to form one long string, with the
1031 	 * optional @separator inserted between each of them. The returned string
1032 	 * should be freed with g_free().
1033 	 *
1034 	 * If @str_array has no items, the return value will be an
1035 	 * empty string. If @str_array contains a single item, @separator will not
1036 	 * appear in the resulting string.
1037 	 *
1038 	 * Params:
1039 	 *     separator = a string to insert between each of the
1040 	 *         strings, or %NULL
1041 	 *     strArray = a %NULL-terminated array of strings to join
1042 	 *
1043 	 * Return: a newly-allocated string containing all of the strings joined
1044 	 *     together, with @separator between them
1045 	 */
1046 	public static string strjoinv(string separator, string[] strArray)
1047 	{
1048 		auto retStr = g_strjoinv(Str.toStringz(separator), Str.toStringzArray(strArray));
1049 		
1050 		scope(exit) Str.freeString(retStr);
1051 		return Str.toString(retStr);
1052 	}
1053 
1054 	/**
1055 	 * Portability wrapper that calls strlcat() on systems which have it,
1056 	 * and emulates it otherwise. Appends nul-terminated @src string to @dest,
1057 	 * guaranteeing nul-termination for @dest. The total size of @dest won't
1058 	 * exceed @dest_size.
1059 	 *
1060 	 * At most @dest_size - 1 characters will be copied. Unlike strncat(),
1061 	 * @dest_size is the full size of dest, not the space left over. This
1062 	 * function does not allocate memory. It always nul-terminates (unless
1063 	 * @dest_size == 0 or there were no nul characters in the @dest_size
1064 	 * characters of dest to start with).
1065 	 *
1066 	 * Caveat: this is supposedly a more secure alternative to strcat() or
1067 	 * strncat(), but for real security g_strconcat() is harder to mess up.
1068 	 *
1069 	 * Params:
1070 	 *     dest = destination buffer, already containing one nul-terminated string
1071 	 *     src = source buffer
1072 	 *     destSize = length of @dest buffer in bytes (not length of existing string
1073 	 *         inside @dest)
1074 	 *
1075 	 * Return: size of attempted result, which is MIN (dest_size, strlen
1076 	 *     (original dest)) + strlen (src), so if retval >= dest_size,
1077 	 *     truncation occurred.
1078 	 */
1079 	public static size_t strlcat(string dest, string src, size_t destSize)
1080 	{
1081 		return g_strlcat(Str.toStringz(dest), Str.toStringz(src), destSize);
1082 	}
1083 
1084 	/**
1085 	 * Portability wrapper that calls strlcpy() on systems which have it,
1086 	 * and emulates strlcpy() otherwise. Copies @src to @dest; @dest is
1087 	 * guaranteed to be nul-terminated; @src must be nul-terminated;
1088 	 * @dest_size is the buffer size, not the number of bytes to copy.
1089 	 *
1090 	 * At most @dest_size - 1 characters will be copied. Always nul-terminates
1091 	 * (unless @dest_size is 0). This function does not allocate memory. Unlike
1092 	 * strncpy(), this function doesn't pad @dest (so it's often faster). It
1093 	 * returns the size of the attempted result, strlen (src), so if
1094 	 * @retval >= @dest_size, truncation occurred.
1095 	 *
1096 	 * Caveat: strlcpy() is supposedly more secure than strcpy() or strncpy(),
1097 	 * but if you really want to avoid screwups, g_strdup() is an even better
1098 	 * idea.
1099 	 *
1100 	 * Params:
1101 	 *     dest = destination buffer
1102 	 *     src = source buffer
1103 	 *     destSize = length of @dest in bytes
1104 	 *
1105 	 * Return: length of @src
1106 	 */
1107 	public static size_t strlcpy(string dest, string src, size_t destSize)
1108 	{
1109 		return g_strlcpy(Str.toStringz(dest), Str.toStringz(src), destSize);
1110 	}
1111 
1112 	/**
1113 	 * A case-insensitive string comparison, corresponding to the standard
1114 	 * strncasecmp() function on platforms which support it. It is similar
1115 	 * to g_strcasecmp() except it only compares the first @n characters of
1116 	 * the strings.
1117 	 *
1118 	 * Deprecated: The problem with g_strncasecmp() is that it does
1119 	 * the comparison by calling toupper()/tolower(). These functions
1120 	 * are locale-specific and operate on single bytes. However, it is
1121 	 * impossible to handle things correctly from an internationalization
1122 	 * standpoint by operating on bytes, since characters may be multibyte.
1123 	 * Thus g_strncasecmp() is broken if your string is guaranteed to be
1124 	 * ASCII, since it is locale-sensitive, and it's broken if your string
1125 	 * is localized, since it doesn't work on many encodings at all,
1126 	 * including UTF-8, EUC-JP, etc.
1127 	 *
1128 	 * There are therefore two replacement techniques: g_ascii_strncasecmp(),
1129 	 * which only works on ASCII and is not locale-sensitive, and
1130 	 * g_utf8_casefold() followed by strcmp() on the resulting strings,
1131 	 * which is good for case-insensitive sorting of UTF-8.
1132 	 *
1133 	 * Params:
1134 	 *     s1 = a string
1135 	 *     s2 = a string to compare with @s1
1136 	 *     n = the maximum number of characters to compare
1137 	 *
1138 	 * Return: 0 if the strings match, a negative value if @s1 < @s2,
1139 	 *     or a positive value if @s1 > @s2.
1140 	 */
1141 	public static int strncasecmp(string s1, string s2, uint n)
1142 	{
1143 		return g_strncasecmp(Str.toStringz(s1), Str.toStringz(s2), n);
1144 	}
1145 
1146 	/**
1147 	 * Duplicates the first @n bytes of a string, returning a newly-allocated
1148 	 * buffer @n + 1 bytes long which will always be nul-terminated. If @str
1149 	 * is less than @n bytes long the buffer is padded with nuls. If @str is
1150 	 * %NULL it returns %NULL. The returned value should be freed when no longer
1151 	 * needed.
1152 	 *
1153 	 * To copy a number of characters from a UTF-8 encoded string,
1154 	 * use g_utf8_strncpy() instead.
1155 	 *
1156 	 * Params:
1157 	 *     str = the string to duplicate
1158 	 *     n = the maximum number of bytes to copy from @str
1159 	 *
1160 	 * Return: a newly-allocated buffer containing the first @n bytes
1161 	 *     of @str, nul-terminated
1162 	 */
1163 	public static string strndup(string str, size_t n)
1164 	{
1165 		auto retStr = g_strndup(Str.toStringz(str), n);
1166 		
1167 		scope(exit) Str.freeString(retStr);
1168 		return Str.toString(retStr);
1169 	}
1170 
1171 	/**
1172 	 * Creates a new string @length bytes long filled with @fill_char.
1173 	 * The returned string should be freed when no longer needed.
1174 	 *
1175 	 * Params:
1176 	 *     length = the length of the new string
1177 	 *     fillChar = the byte to fill the string with
1178 	 *
1179 	 * Return: a newly-allocated string filled the @fill_char
1180 	 */
1181 	public static string strnfill(size_t length, char fillChar)
1182 	{
1183 		auto retStr = g_strnfill(length, fillChar);
1184 		
1185 		scope(exit) Str.freeString(retStr);
1186 		return Str.toString(retStr);
1187 	}
1188 
1189 	/**
1190 	 * Reverses all of the bytes in a string. For example,
1191 	 * `g_strreverse ("abcdef")` will result in "fedcba".
1192 	 *
1193 	 * Note that g_strreverse() doesn't work on UTF-8 strings
1194 	 * containing multibyte characters. For that purpose, use
1195 	 * g_utf8_strreverse().
1196 	 *
1197 	 * Params:
1198 	 *     str = the string to reverse
1199 	 *
1200 	 * Return: the same pointer passed in as @string
1201 	 */
1202 	public static string strreverse(string str)
1203 	{
1204 		auto retStr = g_strreverse(Str.toStringz(str));
1205 		
1206 		scope(exit) Str.freeString(retStr);
1207 		return Str.toString(retStr);
1208 	}
1209 
1210 	/**
1211 	 * Searches the string @haystack for the last occurrence
1212 	 * of the string @needle.
1213 	 *
1214 	 * Params:
1215 	 *     haystack = a nul-terminated string
1216 	 *     needle = the nul-terminated string to search for
1217 	 *
1218 	 * Return: a pointer to the found occurrence, or
1219 	 *     %NULL if not found.
1220 	 */
1221 	public static string strrstr(string haystack, string needle)
1222 	{
1223 		auto retStr = g_strrstr(Str.toStringz(haystack), Str.toStringz(needle));
1224 		
1225 		scope(exit) Str.freeString(retStr);
1226 		return Str.toString(retStr);
1227 	}
1228 
1229 	/**
1230 	 * Searches the string @haystack for the last occurrence
1231 	 * of the string @needle, limiting the length of the search
1232 	 * to @haystack_len.
1233 	 *
1234 	 * Params:
1235 	 *     haystack = a nul-terminated string
1236 	 *     haystackLen = the maximum length of @haystack
1237 	 *     needle = the nul-terminated string to search for
1238 	 *
1239 	 * Return: a pointer to the found occurrence, or
1240 	 *     %NULL if not found.
1241 	 */
1242 	public static string strrstrLen(string haystack, ptrdiff_t haystackLen, string needle)
1243 	{
1244 		auto retStr = g_strrstr_len(Str.toStringz(haystack), haystackLen, Str.toStringz(needle));
1245 		
1246 		scope(exit) Str.freeString(retStr);
1247 		return Str.toString(retStr);
1248 	}
1249 
1250 	/**
1251 	 * Returns a string describing the given signal, e.g. "Segmentation fault".
1252 	 * You should use this function in preference to strsignal(), because it
1253 	 * returns a string in UTF-8 encoding, and since not all platforms support
1254 	 * the strsignal() function.
1255 	 *
1256 	 * Params:
1257 	 *     signum = the signal number. See the `signal` documentation
1258 	 *
1259 	 * Return: a UTF-8 string describing the signal. If the signal is unknown,
1260 	 *     it returns "unknown signal (<signum>)".
1261 	 */
1262 	public static string strsignal(int signum)
1263 	{
1264 		return Str.toString(g_strsignal(signum));
1265 	}
1266 
1267 	/**
1268 	 * Splits a string into a maximum of @max_tokens pieces, using the given
1269 	 * @delimiter. If @max_tokens is reached, the remainder of @string is
1270 	 * appended to the last token.
1271 	 *
1272 	 * As an example, the result of g_strsplit (":a:bc::d:", ":", -1) is a
1273 	 * %NULL-terminated vector containing the six strings "", "a", "bc", "", "d"
1274 	 * and "".
1275 	 *
1276 	 * As a special case, the result of splitting the empty string "" is an empty
1277 	 * vector, not a vector containing a single string. The reason for this
1278 	 * special case is that being able to represent a empty vector is typically
1279 	 * more useful than consistent handling of empty elements. If you do need
1280 	 * to represent empty elements, you'll need to check for the empty string
1281 	 * before calling g_strsplit().
1282 	 *
1283 	 * Params:
1284 	 *     str = a string to split
1285 	 *     delimiter = a string which specifies the places at which to split
1286 	 *         the string. The delimiter is not included in any of the resulting
1287 	 *         strings, unless @max_tokens is reached.
1288 	 *     maxTokens = the maximum number of pieces to split @string into.
1289 	 *         If this is less than 1, the string is split completely.
1290 	 *
1291 	 * Return: a newly-allocated %NULL-terminated array of strings. Use
1292 	 *     g_strfreev() to free it.
1293 	 */
1294 	public static string[] strsplit(string str, string delimiter, int maxTokens)
1295 	{
1296 		return Str.toStringArray(g_strsplit(Str.toStringz(str), Str.toStringz(delimiter), maxTokens));
1297 	}
1298 
1299 	/**
1300 	 * Splits @string into a number of tokens not containing any of the characters
1301 	 * in @delimiter. A token is the (possibly empty) longest string that does not
1302 	 * contain any of the characters in @delimiters. If @max_tokens is reached, the
1303 	 * remainder is appended to the last token.
1304 	 *
1305 	 * For example the result of g_strsplit_set ("abc:def/ghi", ":/", -1) is a
1306 	 * %NULL-terminated vector containing the three strings "abc", "def",
1307 	 * and "ghi".
1308 	 *
1309 	 * The result of g_strsplit_set (":def/ghi:", ":/", -1) is a %NULL-terminated
1310 	 * vector containing the four strings "", "def", "ghi", 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 a 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_set().
1318 	 *
1319 	 * Note that this function works on bytes not characters, so it can't be used
1320 	 * to delimit UTF-8 strings for anything but ASCII characters.
1321 	 *
1322 	 * Params:
1323 	 *     str = The string to be tokenized
1324 	 *     delimiters = A nul-terminated string containing bytes that are used
1325 	 *         to split the string.
1326 	 *     maxTokens = The maximum number of tokens to split @string into.
1327 	 *         If this is less than 1, the string is split completely
1328 	 *
1329 	 * Return: a newly-allocated %NULL-terminated array of strings. Use
1330 	 *     g_strfreev() to free it.
1331 	 *
1332 	 * Since: 2.4
1333 	 */
1334 	public static string[] strsplitSet(string str, string delimiters, int maxTokens)
1335 	{
1336 		return Str.toStringArray(g_strsplit_set(Str.toStringz(str), Str.toStringz(delimiters), maxTokens));
1337 	}
1338 
1339 	/**
1340 	 * Searches the string @haystack for the first occurrence
1341 	 * of the string @needle, limiting the length of the search
1342 	 * to @haystack_len.
1343 	 *
1344 	 * Params:
1345 	 *     haystack = a string
1346 	 *     haystackLen = the maximum length of @haystack. Note that -1 is
1347 	 *         a valid length, if @haystack is nul-terminated, meaning it will
1348 	 *         search through the whole string.
1349 	 *     needle = the string to search for
1350 	 *
1351 	 * Return: a pointer to the found occurrence, or
1352 	 *     %NULL if not found.
1353 	 */
1354 	public static string strstrLen(string haystack, ptrdiff_t haystackLen, string needle)
1355 	{
1356 		auto retStr = g_strstr_len(Str.toStringz(haystack), haystackLen, Str.toStringz(needle));
1357 		
1358 		scope(exit) Str.freeString(retStr);
1359 		return Str.toString(retStr);
1360 	}
1361 
1362 	/**
1363 	 * Converts a string to a #gdouble value.
1364 	 * It calls the standard strtod() function to handle the conversion, but
1365 	 * if the string is not completely converted it attempts the conversion
1366 	 * again with g_ascii_strtod(), and returns the best match.
1367 	 *
1368 	 * This function should seldom be used. The normal situation when reading
1369 	 * numbers not for human consumption is to use g_ascii_strtod(). Only when
1370 	 * you know that you must expect both locale formatted and C formatted numbers
1371 	 * should you use this. Make sure that you don't pass strings such as comma
1372 	 * separated lists of values, since the commas may be interpreted as a decimal
1373 	 * point in some locales, causing unexpected results.
1374 	 *
1375 	 * Params:
1376 	 *     nptr = the string to convert to a numeric value.
1377 	 *     endptr = if non-%NULL, it returns the
1378 	 *         character after the last character used in the conversion.
1379 	 *
1380 	 * Return: the #gdouble value.
1381 	 */
1382 	public static double strtod(string nptr, out string endptr)
1383 	{
1384 		char* outendptr = null;
1385 		
1386 		auto p = g_strtod(Str.toStringz(nptr), &outendptr);
1387 		
1388 		endptr = Str.toString(outendptr);
1389 		
1390 		return p;
1391 	}
1392 
1393 	/**
1394 	 * Converts a string to upper case.
1395 	 *
1396 	 * Deprecated: This function is totally broken for the reasons
1397 	 * discussed in the g_strncasecmp() docs - use g_ascii_strup()
1398 	 * or g_utf8_strup() instead.
1399 	 *
1400 	 * Params:
1401 	 *     str = the string to convert
1402 	 *
1403 	 * Return: the string
1404 	 */
1405 	public static string strup(string str)
1406 	{
1407 		auto retStr = g_strup(Str.toStringz(str));
1408 		
1409 		scope(exit) Str.freeString(retStr);
1410 		return Str.toString(retStr);
1411 	}
1412 
1413 	/** */
1414 	public static GType strvGetType()
1415 	{
1416 		return g_strv_get_type();
1417 	}
1418 
1419 	/**
1420 	 * Returns the length of the given %NULL-terminated
1421 	 * string array @str_array.
1422 	 *
1423 	 * Params:
1424 	 *     strArray = a %NULL-terminated array of strings
1425 	 *
1426 	 * Return: length of @str_array.
1427 	 *
1428 	 * Since: 2.6
1429 	 */
1430 	public static uint strvLength(string[] strArray)
1431 	{
1432 		return g_strv_length(Str.toStringzArray(strArray));
1433 	}
1434 
1435 	/**
1436 	 * Checks if @strv contains @str. @strv must not be %NULL.
1437 	 *
1438 	 * Params:
1439 	 *     strv = a %NULL-terminated array of strings
1440 	 *     str = a string
1441 	 *
1442 	 * Return: %TRUE if @str is an element of @strv, according to g_str_equal().
1443 	 *
1444 	 * Since: 2.44
1445 	 */
1446 	public static bool strvContains(string strv, string str)
1447 	{
1448 		return g_strv_contains(Str.toStringz(strv), Str.toStringz(str)) != 0;
1449 	}
1450 
1451 	/**
1452 	 * An implementation of the GNU vasprintf() function which supports
1453 	 * positional parameters, as specified in the Single Unix Specification.
1454 	 * This function is similar to g_vsprintf(), except that it allocates a
1455 	 * string to hold the output, instead of putting the output in a buffer
1456 	 * you allocate in advance.
1457 	 *
1458 	 * Params:
1459 	 *     str = the return location for the newly-allocated string.
1460 	 *     format = a standard printf() format string, but notice
1461 	 *         [string precision pitfalls][string-precision]
1462 	 *     args = the list of arguments to insert in the output.
1463 	 *
1464 	 * Return: the number of bytes printed.
1465 	 *
1466 	 * Since: 2.4
1467 	 */
1468 	public static int vasprintf(string[] str, string format, void* args)
1469 	{
1470 		return g_vasprintf(Str.toStringzArray(str), Str.toStringz(format), args);
1471 	}
1472 
1473 	/**
1474 	 * An implementation of the standard fprintf() function which supports
1475 	 * positional parameters, as specified in the Single Unix Specification.
1476 	 *
1477 	 * Params:
1478 	 *     file = the stream to write to.
1479 	 *     format = a standard printf() format string, but notice
1480 	 *         [string precision pitfalls][string-precision]
1481 	 *     args = the list of arguments to insert in the output.
1482 	 *
1483 	 * Return: the number of bytes printed.
1484 	 *
1485 	 * Since: 2.2
1486 	 */
1487 	public static int vfprintf(FILE* file, string format, void* args)
1488 	{
1489 		return g_vfprintf(file, Str.toStringz(format), args);
1490 	}
1491 
1492 	/**
1493 	 * An implementation of the standard vprintf() function which supports
1494 	 * positional parameters, as specified in the Single Unix Specification.
1495 	 *
1496 	 * Params:
1497 	 *     format = a standard printf() format string, but notice
1498 	 *         [string precision pitfalls][string-precision]
1499 	 *     args = the list of arguments to insert in the output.
1500 	 *
1501 	 * Return: the number of bytes printed.
1502 	 *
1503 	 * Since: 2.2
1504 	 */
1505 	public static int vprintf(string format, void* args)
1506 	{
1507 		return g_vprintf(Str.toStringz(format), args);
1508 	}
1509 
1510 	/**
1511 	 * A safer form of the standard vsprintf() function. The output is guaranteed
1512 	 * to not exceed @n characters (including the terminating nul character), so
1513 	 * it is easy to ensure that a buffer overflow cannot occur.
1514 	 *
1515 	 * See also g_strdup_vprintf().
1516 	 *
1517 	 * In versions of GLib prior to 1.2.3, this function may return -1 if the
1518 	 * output was truncated, and the truncated string may not be nul-terminated.
1519 	 * In versions prior to 1.3.12, this function returns the length of the output
1520 	 * string.
1521 	 *
1522 	 * The return value of g_vsnprintf() conforms to the vsnprintf() function
1523 	 * as standardized in ISO C99. Note that this is different from traditional
1524 	 * vsnprintf(), which returns the length of the output string.
1525 	 *
1526 	 * The format string may contain positional parameters, as specified in
1527 	 * the Single Unix Specification.
1528 	 *
1529 	 * Params:
1530 	 *     str = the buffer to hold the output.
1531 	 *     n = the maximum number of bytes to produce (including the
1532 	 *         terminating nul character).
1533 	 *     format = a standard printf() format string, but notice
1534 	 *         string precision pitfalls][string-precision]
1535 	 *     args = the list of arguments to insert in the output.
1536 	 *
1537 	 * Return: the number of bytes which would be produced if the buffer
1538 	 *     was large enough.
1539 	 */
1540 	public static int vsnprintf(string str, gulong n, string format, void* args)
1541 	{
1542 		return g_vsnprintf(Str.toStringz(str), n, Str.toStringz(format), args);
1543 	}
1544 
1545 	/**
1546 	 * An implementation of the standard vsprintf() function which supports
1547 	 * positional parameters, as specified in the Single Unix Specification.
1548 	 *
1549 	 * Params:
1550 	 *     str = the buffer to hold the output.
1551 	 *     format = a standard printf() format string, but notice
1552 	 *         [string precision pitfalls][string-precision]
1553 	 *     args = the list of arguments to insert in the output.
1554 	 *
1555 	 * Return: the number of bytes printed.
1556 	 *
1557 	 * Since: 2.2
1558 	 */
1559 	public static int vsprintf(string str, string format, void* args)
1560 	{
1561 		return g_vsprintf(Str.toStringz(str), Str.toStringz(format), args);
1562 	}
1563 }