March 26, 2013 [Issue 9045] Feature request for std.asscii => function isNewline | ||||
---|---|---|---|---|
| ||||
Posted in reply to bioinfornatics | http://d.puremagic.com/issues/show_bug.cgi?id=9045 Nick Sabalausky <cbkbbejeap@mailinator.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |cbkbbejeap@mailinator.com --- Comment #10 from Nick Sabalausky <cbkbbejeap@mailinator.com> 2013-03-26 10:04:56 PDT --- While an 'isNewline(dchar)' func wouldn't work for reasons already discussed, what *would* work and be very helpful IMO, is something similar to the 'std.conv.parse(...)' functions. Ie, just like this, but properly templated, range-ified and UTF8/16-ified: /// If 'str' starts with a Unix, Windows, Unicode or Mac9 newline, it is /// removed from 'str' and returned. Otherwise, null is returned. dstring parseNewline(ref dstring str) { if(str.empty) return null; dstring ret; // Newlines are as defined in: // http://www.unicode.org/reports/tr18/#Line_Boundaries switch(str[0]) { case '\r': if(str.length > 1 && str[1] == '\n') { ret = str[0..2]; str = str[2..$]; break; } goto case; case '\n': case '\f': case '\v': case '\x85': case paraSep: case lineSep: ret = str[0..1]; str = str[1..$]; break; default: ret = null; break; } return ret; } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 29, 2013 [Issue 9045] Feature request for std.asscii => function isNewline | ||||
---|---|---|---|---|
| ||||
Posted in reply to bioinfornatics | http://d.puremagic.com/issues/show_bug.cgi?id=9045 --- Comment #11 from Nick Sabalausky <cbkbbejeap@mailinator.com> 2013-03-28 17:35:23 PDT --- *** Issue 8880 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation