Browse Source

Made a harder regression test with extreme values and found a typo in UTF-8 decoding from yesterday.

David Piuva 5 years ago
parent
commit
0f00e58258

+ 2 - 2
Source/DFPSR/base/text.cpp

@@ -372,10 +372,10 @@ static void feedStringFromFileBuffer_UTF8(const UTF32WriterFunction &reciever, c
 					character = byteA & 0b00011111;
 					character = byteA & 0b00011111;
 					extraBytes = 1;
 					extraBytes = 1;
 				} else if (byteA < 0b11110000) { // Less than four leading ones
 				} else if (byteA < 0b11110000) { // Less than four leading ones
-					character = byteA & 0b00011111;
+					character = byteA & 0b00001111;
 					extraBytes = 2;
 					extraBytes = 2;
 				} else if (byteA < 0b11111000) { // Less than five leading ones
 				} else if (byteA < 0b11111000) { // Less than five leading ones
-					character = byteA & 0b00011111;
+					character = byteA & 0b00000111;
 					extraBytes = 3;
 					extraBytes = 3;
 				} else {
 				} else {
 					// Invalid UTF-8 format
 					// Invalid UTF-8 format

+ 1 - 0
Source/test/tests/TextEncodingTest.cpp

@@ -42,6 +42,7 @@ Xin chào bạn của tôi
 ಹಲೋ ನನ್ನ ಸ್ನೇಹಿತನೇ
 ಹಲೋ ನನ್ನ ಸ್ನೇಹಿತನೇ
 Silav hevalê min
 Silav hevalê min
 اهلا صديقي
 اهلا صديقي
+𐐷
 )QUOTE";
 )QUOTE";
 String expected_utf8 = unicodeContent + U"\nThis is UTF-8";
 String expected_utf8 = unicodeContent + U"\nThis is UTF-8";
 String expected_utf16le = unicodeContent + U"\nThis is UTF-16 Little Endian";
 String expected_utf16le = unicodeContent + U"\nThis is UTF-16 Little Endian";

BIN
Source/test/tests/resources/BomUtf16Be.txt


BIN
Source/test/tests/resources/BomUtf16Le.txt


+ 1 - 0
Source/test/tests/resources/BomUtf8.txt

@@ -23,5 +23,6 @@ Xin chào bạn của tôi
 ಹಲೋ ನನ್ನ ಸ್ನೇಹಿತನೇ
 ಹಲೋ ನನ್ನ ಸ್ನೇಹಿತನೇ
 Silav hevalê min
 Silav hevalê min
 اهلا صديقي
 اهلا صديقي
+𐐷
 
 
 This is UTF-8
 This is UTF-8