Re: parse string as char

2015-02-09 Thread Kagamin via Digitalmars-d-learn
https://github.com/Hackerpilot/libdparse/blob/master/src/std/d/lexer.d#L1491

Re: parse string as char

2015-02-09 Thread FG via Digitalmars-d-learn
Of course consuming it dchar by dchar also works: string s = `\tabŁŃ\r\nx`; assert(parseDchar(s) == '\t'); assert(parseDchar(s) == 'a'); assert(parseDchar(s) == 'b'); assert(parseDchar(s) == 'Ł'); assert(parseDchar(s) == 'Ń'); assert(parseDchar(s) == '\r'); assert(

Re: parse string as char

2015-02-09 Thread FG via Digitalmars-d-learn
On 2015-02-09 at 03:40, 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

Re: parse string as char

2015-02-08 Thread Rikki Cattermole via Digitalmars-d-learn
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 h

parse string as char

2015-02-08 Thread Timothee Cour via Digitalmars-d-learn
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 doesn't work (`\n`.to!char do