Skip to content

Commit 90d8397

Browse files
committed
#169-Test CppStringT::splitlines() with char and wchar_t
Completed. Validated Led to a simplification - makes a difference with Python default behavior with Unicode chars.
1 parent c892008 commit 90d8397

File tree

3 files changed

+240
-70
lines changed

3 files changed

+240
-70
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,8 @@
3434
# Visual Studio specifics
3535
.vs
3636
x64
37+
Debug
38+
Release
39+
40+
# CppStrings specifics
41+
archive

cpp-strings-tests/cpp-strings-tests.cpp

Lines changed: 219 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -701,53 +701,53 @@ namespace cppstringstests
701701
TEST_METHOD(count)
702702
{
703703
pcs::CppString s("abcabcabcdefabca bca bcabca");
704-
Assert::AreEqual(3ULL, s.count("abca"));
705-
Assert::AreEqual(6ULL, s.count("bca"));
706-
Assert::AreEqual(0ULL, s.count("A"));
707-
Assert::AreEqual(2ULL, s.count("abca", 4));
708-
Assert::AreEqual(5ULL, s.count("bca", 2));
709-
Assert::AreEqual(0ULL, s.count("A", 3));
710-
Assert::AreEqual(1ULL, s.count("abca", 4, s.size() - 5));
711-
Assert::AreEqual(4ULL, s.count("bca", 2, s.size() - 2));
712-
Assert::AreEqual(0ULL, s.count("A", 3, s.size() + 4));
704+
Assert::AreEqual(pcs::CppString::size_type(3), s.count("abca"));
705+
Assert::AreEqual(pcs::CppString::size_type(6), s.count("bca"));
706+
Assert::AreEqual(pcs::CppString::size_type(0), s.count("A"));
707+
Assert::AreEqual(pcs::CppString::size_type(2), s.count("abca", 4));
708+
Assert::AreEqual(pcs::CppString::size_type(5), s.count("bca", 2));
709+
Assert::AreEqual(pcs::CppString::size_type(0), s.count("A", 3));
710+
Assert::AreEqual(pcs::CppString::size_type(1), s.count("abca", 4, s.size() - 5));
711+
Assert::AreEqual(pcs::CppString::size_type(4), s.count("bca", 2, s.size() - 2));
712+
Assert::AreEqual(pcs::CppString::size_type(0), s.count("A", 3, s.size() + 4));
713713

714714
pcs::CppWString ws(L"abcabcabcdefabca bca bcabca");
715-
Assert::AreEqual(3ULL, ws.count(L"abca"));
716-
Assert::AreEqual(6ULL, ws.count(L"bca"));
717-
Assert::AreEqual(0ULL, ws.count(L"A"));
718-
Assert::AreEqual(2ULL, ws.count(L"abca", 4));
719-
Assert::AreEqual(5ULL, ws.count(L"bca", 2));
720-
Assert::AreEqual(0ULL, ws.count(L"A", 3));
721-
Assert::AreEqual(1ULL, ws.count(L"abca", 4, s.size() - 5));
722-
Assert::AreEqual(4ULL, ws.count(L"bca", 2, s.size() - 2));
723-
Assert::AreEqual(0ULL, ws.count(L"A", 3, s.size() + 4));
715+
Assert::AreEqual(pcs::CppString::size_type(3), ws.count(L"abca"));
716+
Assert::AreEqual(pcs::CppString::size_type(6), ws.count(L"bca"));
717+
Assert::AreEqual(pcs::CppString::size_type(0), ws.count(L"A"));
718+
Assert::AreEqual(pcs::CppString::size_type(2), ws.count(L"abca", 4));
719+
Assert::AreEqual(pcs::CppString::size_type(5), ws.count(L"bca", 2));
720+
Assert::AreEqual(pcs::CppString::size_type(0), ws.count(L"A", 3));
721+
Assert::AreEqual(pcs::CppString::size_type(1), ws.count(L"abca", 4, s.size() - 5));
722+
Assert::AreEqual(pcs::CppString::size_type(4), ws.count(L"bca", 2, s.size() - 2));
723+
Assert::AreEqual(pcs::CppString::size_type(0), ws.count(L"A", 3, s.size() + 4));
724724
}
725725

726726
TEST_METHOD(count_n)
727727
{
728728
pcs::CppString s("abcabcabcdefabca bca bcabca");
729729
const pcs::CppString::size_type len{ s.size() };
730-
Assert::AreEqual(3ULL, s.count_n("abca", 0, len));
731-
Assert::AreEqual(6ULL, s.count_n("bca", 0, len));
732-
Assert::AreEqual(0ULL, s.count_n("A", 0, len));
733-
Assert::AreEqual(2ULL, s.count_n("abca", 4, len - 4));
734-
Assert::AreEqual(5ULL, s.count_n("bca", 2, len - 2));
735-
Assert::AreEqual(0ULL, s.count_n("A", 3, len - 3));
736-
Assert::AreEqual(1ULL, s.count_n("abca", 4, len - 5));
737-
Assert::AreEqual(4ULL, s.count_n("bca", 2, len - 3));
738-
Assert::AreEqual(0ULL, s.count_n("A", 3, len + 4));
730+
Assert::AreEqual(pcs::CppString::size_type(3), s.count_n("abca", 0, len));
731+
Assert::AreEqual(pcs::CppString::size_type(6), s.count_n("bca", 0, len));
732+
Assert::AreEqual(pcs::CppString::size_type(0), s.count_n("A", 0, len));
733+
Assert::AreEqual(pcs::CppString::size_type(2), s.count_n("abca", 4, len - 4));
734+
Assert::AreEqual(pcs::CppString::size_type(5), s.count_n("bca", 2, len - 2));
735+
Assert::AreEqual(pcs::CppString::size_type(0), s.count_n("A", 3, len - 3));
736+
Assert::AreEqual(pcs::CppString::size_type(1), s.count_n("abca", 4, len - 5));
737+
Assert::AreEqual(pcs::CppString::size_type(4), s.count_n("bca", 2, len - 3));
738+
Assert::AreEqual(pcs::CppString::size_type(0), s.count_n("A", 3, len + 4));
739739

740740
pcs::CppWString ws(L"abcabcabcdefabca bca bcabca");
741741
const pcs::CppWString::size_type wlen{ ws.size() };
742-
Assert::AreEqual(3ULL, ws.count_n(L"abca", 0, wlen));
743-
Assert::AreEqual(6ULL, ws.count_n(L"bca", 0, wlen));
744-
Assert::AreEqual(0ULL, ws.count_n(L"A", 0, wlen));
745-
Assert::AreEqual(2ULL, ws.count_n(L"abca", 4, wlen - 4));
746-
Assert::AreEqual(5ULL, ws.count_n(L"bca", 2, wlen - 2));
747-
Assert::AreEqual(0ULL, ws.count_n(L"A", 3, wlen - 3));
748-
Assert::AreEqual(1ULL, ws.count_n(L"abca", 4, wlen - 5));
749-
Assert::AreEqual(4ULL, ws.count_n(L"bca", 2, wlen - 3));
750-
Assert::AreEqual(0ULL, ws.count_n(L"A", 3, wlen + 4));
742+
Assert::AreEqual(pcs::CppString::size_type(3), ws.count_n(L"abca", 0, wlen));
743+
Assert::AreEqual(pcs::CppString::size_type(6), ws.count_n(L"bca", 0, wlen));
744+
Assert::AreEqual(pcs::CppString::size_type(0), ws.count_n(L"A", 0, wlen));
745+
Assert::AreEqual(pcs::CppString::size_type(2), ws.count_n(L"abca", 4, wlen - 4));
746+
Assert::AreEqual(pcs::CppString::size_type(5), ws.count_n(L"bca", 2, wlen - 2));
747+
Assert::AreEqual(pcs::CppString::size_type(0), ws.count_n(L"A", 3, wlen - 3));
748+
Assert::AreEqual(pcs::CppString::size_type(1), ws.count_n(L"abca", 4, wlen - 5));
749+
Assert::AreEqual(pcs::CppString::size_type(4), ws.count_n(L"bca", 2, wlen - 3));
750+
Assert::AreEqual(pcs::CppString::size_type(0), ws.count_n(L"A", 3, wlen + 4));
751751
}
752752

753753
TEST_METHOD(endswith)
@@ -3312,5 +3312,188 @@ namespace cppstringstests
33123312
Assert::AreEqual(L"", wres[8].c_str());
33133313
}
33143314

3315+
TEST_METHOD(splitline)
3316+
{
3317+
#pragma warning(push)
3318+
#pragma warning(disable: 4566) // to get no warning when current page code is not compatible with next unicode points
3319+
{
3320+
CppString text{ "\vabc\013cde\fefg\x0cghi\x1cijk\x1dklm\x1dmno\r\n\nopq\rqrs\vstu\ruvw\nwxy\r\nzzz\x0c.\r" };
3321+
std::vector<CppString> lines{ text.splitlines() };
3322+
std::vector<CppString> expected{ "", "abc", "cde", "efg", "ghi", "ijk", "klm", "mno", "", "opq", "qrs", "stu", "uvw", "wxy", "zzz", "." };
3323+
auto exp_it{ expected.cbegin() };
3324+
auto lin_it{ lines.cbegin() };
3325+
for (; lin_it != lines.cend() && exp_it != expected.cend(); ++lin_it, ++exp_it) {
3326+
Assert::AreEqual(exp_it->c_str(), lin_it->c_str());
3327+
}
3328+
Assert::IsFalse(lin_it != lines.cend());
3329+
Assert::IsFalse(exp_it != expected.cend());
3330+
}
3331+
3332+
{
3333+
CppString text{ "\vabc\013cde\fefg\x0cghi\x1cijk\x1dklm\x1dmno\r\n\nopq\rqrs\vstu\ruvw\nwxy\r\nzzz\x0c.\r\n" };
3334+
std::vector<CppString> lines{ text.splitlines() };
3335+
std::vector<CppString> expected{ "", "abc", "cde", "efg", "ghi", "ijk", "klm", "mno", "", "opq", "qrs", "stu", "uvw", "wxy", "zzz", "." };
3336+
auto exp_it{ expected.cbegin() };
3337+
auto lin_it{ lines.cbegin() };
3338+
for (; lin_it != lines.cend() && exp_it != expected.cend(); ++lin_it, ++exp_it) {
3339+
Assert::AreEqual(exp_it->c_str(), lin_it->c_str());
3340+
}
3341+
Assert::IsFalse(lin_it != lines.cend());
3342+
Assert::IsFalse(exp_it != expected.cend());
3343+
}
3344+
3345+
{
3346+
CppString text{ "\vabc\013cde\fefg\x0cghi\x1cijk\x1dklm\x1dmno\r\n\nopq\rqrs\vstu\ruvw\nwxy\r\nzzz\x0c.\n\r" };
3347+
std::vector<CppString> lines{ text.splitlines() };
3348+
std::vector<CppString> expected{ "", "abc", "cde", "efg", "ghi", "ijk", "klm", "mno", "", "opq", "qrs", "stu", "uvw", "wxy", "zzz", ".", "" };
3349+
auto exp_it{ expected.cbegin() };
3350+
auto lin_it{ lines.cbegin() };
3351+
for (; lin_it != lines.cend() && exp_it != expected.cend(); ++lin_it, ++exp_it) {
3352+
Assert::AreEqual(exp_it->c_str(), lin_it->c_str());
3353+
}
3354+
Assert::IsFalse(lin_it != lines.cend());
3355+
Assert::IsFalse(exp_it != expected.cend());
3356+
}
3357+
3358+
{
3359+
CppString text{ "\vabc\013cde\fefg\x0cghi\x1cijk\x1dklm\x1dmno\r\n\nopq\rqrs\vstu\ruvw\nwxy\r\nzzz\x0c.\r" };
3360+
std::vector<CppString> lines{ text.splitlines(true) };
3361+
std::vector<CppString> expected{
3362+
"\v", "abc\013", "cde\f", "efg\x0c", "ghi\x1c", "ijk\x1d", "klm\x1d", "mno\r\n",
3363+
"\n", "opq\r", "qrs\v", "stu\r", "uvw\n", "wxy\r\n", "zzz\x0c", ".\r"
3364+
};
3365+
auto exp_it{ expected.cbegin() };
3366+
auto lin_it{ lines.cbegin() };
3367+
for (; lin_it != lines.cend() && exp_it != expected.cend(); ++lin_it, ++exp_it) {
3368+
Assert::AreEqual(exp_it->c_str(), lin_it->c_str());
3369+
}
3370+
Assert::IsFalse(lin_it != lines.cend());
3371+
Assert::IsFalse(exp_it != expected.cend());
3372+
}
3373+
3374+
{
3375+
CppString text{ "\vabc\013cde\fefg\x0cghi\x1cijk\x1dklm\x1dmno\r\n\nopq\rqrs\vstu\ruvw\nwxy\r\nzzz\x0c.\r\n" };
3376+
std::vector<CppString> lines{ text.splitlines(true) };
3377+
std::vector<CppString> expected{
3378+
"\v", "abc\013", "cde\f", "efg\x0c", "ghi\x1c", "ijk\x1d", "klm\x1d", "mno\r\n",
3379+
"\n", "opq\r", "qrs\v", "stu\r", "uvw\n", "wxy\r\n", "zzz\x0c", ".\r\n"
3380+
};
3381+
auto exp_it{ expected.cbegin() };
3382+
auto lin_it{ lines.cbegin() };
3383+
for (; lin_it != lines.cend() && exp_it != expected.cend(); ++lin_it, ++exp_it) {
3384+
Assert::AreEqual(exp_it->c_str(), lin_it->c_str());
3385+
}
3386+
Assert::IsFalse(lin_it != lines.cend());
3387+
Assert::IsFalse(exp_it != expected.cend());
3388+
}
3389+
3390+
{
3391+
CppString text{ "\vabc\013cde\fefg\x0cghi\x1cijk\x1dklm\x1dmno\r\n\nopq\rqrs\vstu\ruvw\nwxy\r\nzzz\x0c.\n\r" };
3392+
std::vector<CppString> lines{ text.splitlines(true) };
3393+
std::vector<CppString> expected{
3394+
"\v", "abc\013", "cde\f", "efg\x0c", "ghi\x1c", "ijk\x1d", "klm\x1d", "mno\r\n",
3395+
"\n", "opq\r", "qrs\v", "stu\r", "uvw\n", "wxy\r\n", "zzz\x0c", ".\n", "\r"
3396+
};
3397+
auto exp_it{ expected.cbegin() };
3398+
auto lin_it{ lines.cbegin() };
3399+
for (; lin_it != lines.cend() && exp_it != expected.cend(); ++lin_it, ++exp_it) {
3400+
Assert::AreEqual(exp_it->c_str(), lin_it->c_str());
3401+
}
3402+
Assert::IsFalse(lin_it != lines.cend());
3403+
Assert::IsFalse(exp_it != expected.cend());
3404+
}
3405+
3406+
3407+
{
3408+
CppWString wtext{ L"\vabc\013cde\fefg\x0cghi\x1cijk\x1dklm\x1dmno\r\n\nopq\rqrs\vstu\ruvw\nwxy\r\nzzz\x0c.\r" };
3409+
std::vector<CppWString> wlines{ wtext.splitlines() };
3410+
std::vector<CppWString> wexpected{ L"", L"abc", L"cde", L"efg", L"ghi", L"ijk", L"klm", L"mno", L"", L"opq", L"qrs", L"stu", L"uvw", L"wxy", L"zzz", L"."};
3411+
auto exp_it{ wexpected.cbegin() };
3412+
auto lin_it{ wlines.cbegin() };
3413+
for (; lin_it != wlines.cend() && exp_it != wexpected.cend(); ++lin_it, ++exp_it) {
3414+
Assert::AreEqual(exp_it->c_str(), lin_it->c_str());
3415+
}
3416+
Assert::IsFalse(lin_it != wlines.cend());
3417+
Assert::IsFalse(exp_it != wexpected.cend());
3418+
}
3419+
3420+
{
3421+
CppWString wtext{ L"\vabc\013cde\fefg\x0cghi\x1cijk\x1dklm\x1dmno\r\n\nopq\rqrs\vstu\ruvw\nwxy\r\nzzz\x0c.\r\n" };
3422+
std::vector<CppWString> wlines{ wtext.splitlines() };
3423+
std::vector<CppWString> wexpected{ L"", L"abc", L"cde", L"efg", L"ghi", L"ijk", L"klm", L"mno", L"", L"opq", L"qrs", L"stu", L"uvw", L"wxy", L"zzz", L"."};
3424+
auto exp_it{ wexpected.cbegin() };
3425+
auto lin_it{ wlines.cbegin() };
3426+
for (; lin_it != wlines.cend() && exp_it != wexpected.cend(); ++lin_it, ++exp_it) {
3427+
Assert::AreEqual(exp_it->c_str(), lin_it->c_str());
3428+
}
3429+
Assert::IsFalse(lin_it != wlines.cend());
3430+
Assert::IsFalse(exp_it != wexpected.cend());
3431+
}
3432+
3433+
{
3434+
CppWString wtext{ L"\vabc\013cde\fefg\x0cghi\x1cijk\x1dklm\x1dmno\r\n\nopq\rqrs\vstu\ruvw\nwxy\r\nzzz\x0c.\n\r" };
3435+
std::vector<CppWString> wlines{ wtext.splitlines() };
3436+
std::vector<CppWString> wexpected{ L"", L"abc", L"cde", L"efg", L"ghi", L"ijk", L"klm", L"mno", L"", L"opq", L"qrs", L"stu", L"uvw", L"wxy", L"zzz", L".", L""};
3437+
auto exp_it{ wexpected.cbegin() };
3438+
auto lin_it{ wlines.cbegin() };
3439+
for (; lin_it != wlines.cend() && exp_it != wexpected.cend(); ++lin_it, ++exp_it) {
3440+
Assert::AreEqual(exp_it->c_str(), lin_it->c_str());
3441+
}
3442+
Assert::IsFalse(lin_it != wlines.cend());
3443+
Assert::IsFalse(exp_it != wexpected.cend());
3444+
}
3445+
3446+
{
3447+
CppWString wtext{ L"\vabc\013cde\fefg\x0cghi\x1cijk\x1dklm\x1dmno\r\n\nopq\rqrs\vstu\ruvw\nwxy\r\nzzz\x0c.\r" };
3448+
std::vector<CppWString> wlines{ wtext.splitlines(true) };
3449+
std::vector<CppWString> wexpected{
3450+
L"\v", L"abc\013", L"cde\f", L"efg\x0c", L"ghi\x1c", L"ijk\x1d", L"klm\x1d", L"mno\r\n",
3451+
L"\n", L"opq\r", L"qrs\v", L"stu\r", L"uvw\n", L"wxy\r\n", L"zzz\x0c", L".\r"
3452+
};
3453+
auto exp_it{ wexpected.cbegin() };
3454+
auto lin_it{ wlines.cbegin() };
3455+
for (; lin_it != wlines.cend() && exp_it != wexpected.cend(); ++lin_it, ++exp_it) {
3456+
Assert::AreEqual(exp_it->c_str(), lin_it->c_str());
3457+
}
3458+
Assert::IsFalse(lin_it != wlines.cend());
3459+
Assert::IsFalse(exp_it != wexpected.cend());
3460+
}
3461+
3462+
{
3463+
CppWString wtext{ L"\vabc\013cde\fefg\x0cghi\x1cijk\x1dklm\x1dmno\r\n\nopq\rqrs\vstu\ruvw\nwxy\r\nzzz\x0c.\r\n" };
3464+
std::vector<CppWString> wlines{ wtext.splitlines(true) };
3465+
std::vector<CppWString> wexpected{
3466+
L"\v", L"abc\013", L"cde\f", L"efg\x0c", L"ghi\x1c", L"ijk\x1d", L"klm\x1d", L"mno\r\n",
3467+
L"\n", L"opq\r", L"qrs\v", L"stu\r", L"uvw\n", L"wxy\r\n", L"zzz\x0c", L".\r\n"
3468+
};
3469+
auto exp_it{ wexpected.cbegin() };
3470+
auto lin_it{ wlines.cbegin() };
3471+
for (; lin_it != wlines.cend() && exp_it != wexpected.cend(); ++lin_it, ++exp_it) {
3472+
Assert::AreEqual(exp_it->c_str(), lin_it->c_str());
3473+
}
3474+
Assert::IsFalse(lin_it != wlines.cend());
3475+
Assert::IsFalse(exp_it != wexpected.cend());
3476+
}
3477+
3478+
{
3479+
CppWString wtext{ L"\vabc\013cde\fefg\x0cghi\x1cijk\x1dklm\x1dmno\r\n\nopq\rqrs\vstu\ruvw\nwxy\r\nzzz\x0c.\n\r" };
3480+
std::vector<CppWString> wlines{ wtext.splitlines(true) };
3481+
std::vector<CppWString> wexpected{
3482+
L"\v", L"abc\013", L"cde\f", L"efg\x0c", L"ghi\x1c", L"ijk\x1d", L"klm\x1d", L"mno\r\n",
3483+
L"\n", L"opq\r", L"qrs\v", L"stu\r", L"uvw\n", L"wxy\r\n", L"zzz\x0c", L".\n", L"\r"
3484+
};
3485+
auto exp_it{ wexpected.cbegin() };
3486+
auto lin_it{ wlines.cbegin() };
3487+
for (; lin_it != wlines.cend() && exp_it != wexpected.cend(); ++lin_it, ++exp_it) {
3488+
Assert::AreEqual(exp_it->c_str(), lin_it->c_str());
3489+
}
3490+
Assert::IsFalse(lin_it != wlines.cend());
3491+
Assert::IsFalse(exp_it != wexpected.cend());
3492+
}
3493+
3494+
#pragma warning(pop)
3495+
3496+
}
3497+
33153498
};
33163499
}

cpp-strings/cppstrings.h

Lines changed: 16 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,25 +1561,6 @@ namespace pcs // i.e. "pythonic c++ strings"
15611561
}
15621562
}
15631563
res.push_back(this->substr(index, this->size() - index));
1564-
/** /
1565-
const CppStringT whitespace(value_type(' '));
1566-
std::vector<CppStringT> all_words{ this->split(sep) };
1567-
1568-
size_type count = maxsplit;
1569-
auto word_it = all_words.cbegin();
1570-
while (count > 0 && word_it != all_words.cend()) {
1571-
res.insert(res.cbegin(), *word_it);
1572-
--count;
1573-
word_it++;
1574-
}
1575-
1576-
size_type chars_count = 0;
1577-
for (auto it = word_it; it != all_words.cend(); ++it) {
1578-
chars_count += it->size() + 1;
1579-
}
1580-
if (chars_count > 0)
1581-
res.insert(res.cbegin(), this->substr(this->cbegin() + chars_count - 1, this->cend()));
1582-
/**/
15831564
}
15841565

15851566
return res;
@@ -1600,6 +1581,7 @@ namespace pcs // i.e. "pythonic c++ strings"
16001581
* \x1c File Separator
16011582
* \x1d Group Separator
16021583
* \x1e Record Separator
1584+
* Next separators values, detected by Python method splitlines(), are NOT detected with CppStrings
16031585
* \x85 Next Line (C1 Control Code)
16041586
* \u2028 Line Separator
16051587
* \u2029 Paragraph Separator
@@ -1610,21 +1592,16 @@ namespace pcs // i.e. "pythonic c++ strings"
16101592
CppStringT current{};
16111593
bool prev_cr = false;
16121594

1613-
for (const value_type& ch : *this) {
1595+
for (const value_type ch : *this) {
16141596
switch (ch) {
1615-
case value_type('\v'): // Line Tabulation
1616-
case value_type('\x0b'): // Line Tabulation
1617-
case value_type('\f'): // Form Feed
1618-
case value_type('\x0c'): // Form Feed
1619-
case value_type('\x1c'): // File Separator
1620-
case value_type('\x1d'): // Group Separator
1621-
case value_type('\x1e'): // Record Separator
1622-
case value_type('\x85'): // Next Line (C1 Control Code)
1623-
#pragma warning(push)
1624-
#pragma warning(disable: 4566) // to get no warning when current page code is not compatible with next unicode points
1625-
case value_type('\u2028'): // Line Separator
1626-
case value_type('\u2029'): // Paragraph Separator
1627-
#pragma warning(pop)
1597+
case 0x0b: // Line Tabulation, \v as well as \x0b and \013
1598+
case 0x0c: // Form Feed, \f as well as \x0c and \014
1599+
case 0x1c: // File Separator, or \034
1600+
case 0x1d: // Group Separator, or \035
1601+
case 0x1e: // Record Separator, or \036
1602+
//case L'\u0085': // Next Line (C1 Control Code), or \0205
1603+
//case L'\u2028': // Line Separator
1604+
//case L'\u2029': // Paragraph Separator
16281605
if (prev_cr) {
16291606
res.push_back(current);
16301607
current.clear();
@@ -1646,7 +1623,7 @@ namespace pcs // i.e. "pythonic c++ strings"
16461623
prev_cr = true;
16471624
break;
16481625

1649-
case value_type('\n'): // Line Feed
1626+
case value_type('\n'): // Carriage return
16501627
if (keep_end)
16511628
current += ch;
16521629
res.push_back(current);
@@ -1659,12 +1636,17 @@ namespace pcs // i.e. "pythonic c++ strings"
16591636
if (prev_cr) {
16601637
res.push_back(current);
16611638
current.clear();
1639+
prev_cr = false;
16621640
}
16631641
current += ch;
16641642
break;
16651643
}
16661644
}
16671645

1646+
if (prev_cr) {
1647+
res.push_back(current);
1648+
}
1649+
16681650
return res;
16691651
}
16701652

0 commit comments

Comments
 (0)