February 28, 2013
strings follow a special rule for printing: Basically, if you print a string, it gets pretty printed. However, if it becomes a part of a struct, or an array, or any container in general, it becomes printed as a type. EG:

//----
string s = "hello\tworld";
writeln(s); //raw string
writeln([s]);

//----
will print:
hello   world
["hello\tworld"]

My question is: Is there any way to print the string as a type (second example), in a simple fashion? The only way I found is to place it in an array, and then print it using a printf special syntax to strip the []:

writefln("%(%s%)", (&s)[0 .. 1]);
"hello\tworld"

It works, but it is ugly as fuck, and cryptic as hell. Is there any simple format flag that gets the job done simply? There has to be something, since writefln is obviously able to do it, but I can't seem to plug into it dirrectly...