1 module gfmod.core.text;
2 
3 import std.file,
4        std.utf,
5        std.conv,
6        std.encoding,
7        std.array,
8        core.stdc..string;
9 
10 
11 /**
12  * Sanitize a C string from a library.
13  *
14  * Params:
15  * 
16  * inputZ = Zero-terminated string to sanitize.
17  * output = Sanitized ASCII string will be written here. Non-ASCII bytes are replaced by '?'
18  *
19  * Returns: false if at least one character was invalid, true otherwise.
20  */
21 bool sanitizeASCIIInPlace(char[] inputZ) @trusted pure nothrow @nogc
22 {
23     assert(inputZ !is  null);
24     bool allValid = true;
25     foreach(i; 0 .. inputZ.length) if(inputZ[i] >= 0x80)
26     {
27         allValid = false;
28         inputZ[i]    = '?';
29     }
30     return allValid;
31 }
32