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