On 9/02/2015 3:40 p.m., Timothee Cour via Digitalmars-d-learn wrote:
Is there a simple way to parse a string as a char?
eg:
unittest{
   assert(parseChar(`a`)=='a');
   assert(parseChar(`\n`)=='\n'); //NOTE: I'm looking at `\n` not "\n"
   // should also work with other forms of characters, see
http://dlang.org/lex.html
}
Note, std.conv.to <http://std.conv.to> doesn't work (`\n`.to!char does
not work)

Ugh, if you are just wanting to get a singular char in a string just you slices.

assert("mystr"[0] == 'm');

Reply via email to