diff options
author | est31 <MTest31@outlook.com> | 2015-06-17 22:10:22 +0200 |
---|---|---|
committer | est31 <MTest31@outlook.com> | 2015-06-17 22:22:15 +0200 |
commit | 43dab2ffc899133fbd8bb4bf4d209a3bbc70b901 (patch) | |
tree | ffc9e5c0a794380db4e5b746c9a75df84ae69355 /src/unittest | |
parent | 6dcf549ba9d522ed991184401658e85d3554ad8e (diff) | |
download | minetest-43dab2ffc899133fbd8bb4bf4d209a3bbc70b901.tar.gz minetest-43dab2ffc899133fbd8bb4bf4d209a3bbc70b901.tar.bz2 minetest-43dab2ffc899133fbd8bb4bf4d209a3bbc70b901.zip |
Make wrap_rows not wrap inside utf-8 multibyte sequences
Also count multibyte sequences as "one" character.
Adds unittest for the bug reporter's case.
Fixes #2796.
Diffstat (limited to 'src/unittest')
-rw-r--r-- | src/unittest/test_utilities.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/unittest/test_utilities.cpp b/src/unittest/test_utilities.cpp index 6a731c662..9678a81eb 100644 --- a/src/unittest/test_utilities.cpp +++ b/src/unittest/test_utilities.cpp @@ -242,6 +242,14 @@ void TestUtilities::testUTF8() void TestUtilities::testWrapRows() { UASSERT(wrap_rows("12345678",4) == "1234\n5678"); + // test that wrap_rows doesn't wrap inside multibyte sequences + const unsigned char s[] = { + 0x2f, 0x68, 0x6f, 0x6d, 0x65, 0x2f, 0x72, 0x61, 0x70, 0x74, 0x6f, + 0x72, 0x2f, 0xd1, 0x82, 0xd0, 0xb5, 0xd1, 0x81, 0xd1, 0x82, 0x2f, + 0x6d, 0x69, 0x6e, 0x65, 0x74, 0x65, 0x73, 0x74, 0x2f, 0x62, 0x69, + 0x6e, 0x2f, 0x2e, 0x2e, 0}; + std::string str((char *)s); + UASSERT(utf8_to_wide(wrap_rows(str, 20)) != L"<invalid UTF-8 string>"); } |