| 3495 | } |
| 3496 | |
| 3497 | std::string StyledWriter::normalizeEOL(const std::string &text) { |
| 3498 | std::string normalized; |
| 3499 | normalized.reserve(text.length()); |
| 3500 | const char *begin = text.c_str(); |
| 3501 | const char *end = begin + text.length(); |
| 3502 | const char *current = begin; |
| 3503 | while (current != end) { |
| 3504 | char c = *current++; |
| 3505 | if (c == '\r') // mac or dos EOL |
| 3506 | { |
| 3507 | if (*current == '\n') // convert dos EOL |
| 3508 | ++current; |
| 3509 | normalized += '\n'; |
| 3510 | } else // handle unix EOL & other char |
| 3511 | normalized += c; |
| 3512 | } |
| 3513 | return normalized; |
| 3514 | } |
| 3515 | |
| 3516 | // Class StyledStreamWriter |
| 3517 | // ////////////////////////////////////////////////////////////////// |