Skip to content
Prev Previous commit
Next Next commit
fix for fastfloat_strncasecmp for wchar_t and larger char types
  • Loading branch information
dalle committed Nov 20, 2024
commit 50ee38af65944a81e60649c29553062f7a383d47
11 changes: 7 additions & 4 deletions include/fast_float/float_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,15 @@ fastfloat_really_inline constexpr bool is_supported_char_type() {
// Compares two ASCII strings in a case insensitive manner.
template <typename UC>
inline FASTFLOAT_CONSTEXPR14 bool
fastfloat_strncasecmp(UC const *input1, UC const *input2, size_t length) {
char running_diff{0};
fastfloat_strncasecmp(UC const *actual_mixedcase, UC const *expected_lowercase,
size_t length) {
for (size_t i = 0; i < length; ++i) {
running_diff |= (char(input1[i]) ^ char(input2[i]));
UC const actual = actual_mixedcase[i];
if ((actual < 256 ? actual | 32 : actual) != expected_lowercase[i]) {
return false;
}
}
return (running_diff == 0) || (running_diff == 32);
return true;
}

#ifndef FLT_EVAL_METHOD
Expand Down