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