@@ -339,7 +339,7 @@ size_t minipal_convert_utf8_to_utf16(const char* source, size_t sourceLength, CH
339339 missingBytes = 2 ; // Only one byte is guaranteed missing
340340 }
341341 }
342-
342+
343343 currentChar = 0xFFFD ; // Replacement character for invalid sequences
344344 sourceIndex += missingBytes ;
345345 }
@@ -359,19 +359,19 @@ size_t minipal_convert_utf8_to_utf16(const char* source, size_t sourceLength, CH
359359 {
360360 // 4-byte sequence - based on ABNF (Augmented Backus-Naur Form) syntax described at
361361 // https://datatracker.ietf.org/doc/html/rfc3629#section-4
362- if ((sourceIndex + 3 >= sourceLength ) ||
363- ((unsigned char )source [sourceIndex ] < 0xF0 || (unsigned char )source [sourceIndex ] > 0xF4 ) ||
364- ((unsigned char )source [sourceIndex ] == 0xF0 &&
365- ((sourceIndex + 1 >= sourceLength || (unsigned char )source [sourceIndex + 1 ] < 0x90 || (unsigned char )source [sourceIndex + 1 ] > 0xBF ) ||
366- (sourceIndex + 2 >= sourceLength || (unsigned char )source [sourceIndex + 2 ] < 0x80 || (unsigned char )source [sourceIndex + 2 ] > 0xBF ) ||
367- (sourceIndex + 3 >= sourceLength || (unsigned char )source [sourceIndex + 3 ] < 0x80 || (unsigned char )source [sourceIndex + 3 ] > 0xBF ))) ||
362+ if ((sourceIndex + 3 >= sourceLength ) ||
363+ ((unsigned char )source [sourceIndex ] < 0xF0 || (unsigned char )source [sourceIndex ] > 0xF4 ) ||
364+ ((unsigned char )source [sourceIndex ] == 0xF0 &&
365+ ((sourceIndex + 1 >= sourceLength || (unsigned char )source [sourceIndex + 1 ] < 0x90 || (unsigned char )source [sourceIndex + 1 ] > 0xBF ) ||
366+ (sourceIndex + 2 >= sourceLength || (unsigned char )source [sourceIndex + 2 ] < 0x80 || (unsigned char )source [sourceIndex + 2 ] > 0xBF ) ||
367+ (sourceIndex + 3 >= sourceLength || (unsigned char )source [sourceIndex + 3 ] < 0x80 || (unsigned char )source [sourceIndex + 3 ] > 0xBF ))) ||
368368 ((unsigned char )source [sourceIndex ] >= 0xF1 && (unsigned char )source [sourceIndex ] <= 0xF3 &&
369- ((sourceIndex + 1 >= sourceLength || (unsigned char )source [sourceIndex + 1 ] < 0x80 || (unsigned char )source [sourceIndex + 1 ] > 0xBF ) ||
370- (sourceIndex + 2 >= sourceLength || (unsigned char )source [sourceIndex + 2 ] < 0x80 || (unsigned char )source [sourceIndex + 2 ] > 0xBF ) ||
371- (sourceIndex + 3 >= sourceLength || (unsigned char )source [sourceIndex + 3 ] < 0x80 || (unsigned char )source [sourceIndex + 3 ] > 0xBF ))) ||
372- ((unsigned char )source [sourceIndex ] == 0xF4 &&
373- ((sourceIndex + 1 >= sourceLength || (unsigned char )source [sourceIndex + 1 ] < 0x80 || (unsigned char )source [sourceIndex + 1 ] > 0x8F ) ||
374- (sourceIndex + 2 >= sourceLength || (unsigned char )source [sourceIndex + 2 ] < 0x80 || (unsigned char )source [sourceIndex + 2 ] > 0xBF ) ||
369+ ((sourceIndex + 1 >= sourceLength || (unsigned char )source [sourceIndex + 1 ] < 0x80 || (unsigned char )source [sourceIndex + 1 ] > 0xBF ) ||
370+ (sourceIndex + 2 >= sourceLength || (unsigned char )source [sourceIndex + 2 ] < 0x80 || (unsigned char )source [sourceIndex + 2 ] > 0xBF ) ||
371+ (sourceIndex + 3 >= sourceLength || (unsigned char )source [sourceIndex + 3 ] < 0x80 || (unsigned char )source [sourceIndex + 3 ] > 0xBF ))) ||
372+ ((unsigned char )source [sourceIndex ] == 0xF4 &&
373+ ((sourceIndex + 1 >= sourceLength || (unsigned char )source [sourceIndex + 1 ] < 0x80 || (unsigned char )source [sourceIndex + 1 ] > 0x8F ) ||
374+ (sourceIndex + 2 >= sourceLength || (unsigned char )source [sourceIndex + 2 ] < 0x80 || (unsigned char )source [sourceIndex + 2 ] > 0xBF ) ||
375375 (sourceIndex + 3 >= sourceLength || (unsigned char )source [sourceIndex + 3 ] < 0x80 || (unsigned char )source [sourceIndex + 3 ] > 0xBF ))))
376376 {
377377 if (useFallback )
0 commit comments