| 515 | |
| 516 | |
| 517 | std::string |
| 518 | StyledWriter::normalizeEOL( const std::string &text ) |
| 519 | { |
| 520 | std::string normalized; |
| 521 | normalized.reserve( text.length() ); |
| 522 | const char *begin = text.c_str(); |
| 523 | const char *end = begin + text.length(); |
| 524 | const char *current = begin; |
| 525 | while ( current != end ) |
| 526 | { |
| 527 | char c = *current++; |
| 528 | if ( c == '\r' ) // mac or dos EOL |
| 529 | { |
| 530 | if ( *current == '\n' ) // convert dos EOL |
| 531 | ++current; |
| 532 | normalized += '\n'; |
| 533 | } |
| 534 | else // handle unix EOL & other char |
| 535 | normalized += c; |
| 536 | } |
| 537 | return normalized; |
| 538 | } |
| 539 | |
| 540 | |
| 541 | // Class StyledStreamWriter |