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