Bug 8880 – Feature Request into both std.ascii std.uni isNewline
Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-10-23T15:47:00Z
Last change time
2013-03-28T17:35:23Z
Assigned to
nobody
Creator
bioinfornatics
Comments
Comment #0 by bioinfornatics — 2012-10-23T15:47:13Z
both std.ascii std.uni provides isWhite but any provides isNewline
maybe something like
bool isNewline(dchar c) @safe pure nothrow
{
return ( c == 0x0A || c == 0x0D )? isWhite( c ) : false;
}
Comment #1 by bioinfornatics — 2012-10-23T15:57:46Z
unittest
import std.stdio;
import std.ascii;
bool isNewline(dchar c) @safe pure nothrow {
return ( c == 0x0A || c == 0x0D )? isWhite( c ) : false;
}
void main(){
string test1 = "test\n";
string test2 = "test\r\n";
string test3 = "test\r";
foreach( letter; test1 ) writeln( letter, isNewline( letter ) );
foreach( letter; test2 ) writeln( letter, isNewline( letter ) );
foreach( letter; test3 ) writeln( letter, isNewline( letter ) );
}
Comment #2 by bus_dbugzilla — 2013-03-28T17:35:23Z
Duplicate of #9045. Closing this one because #9045 has more discussion.
*** This issue has been marked as a duplicate of issue 9045 ***