OcStringLib: Import MixedStrCmp()

This commit is contained in:
Marvin Häuser 2021-02-27 19:43:15 +01:00 committed by Vitaly Cheptsov
parent 68eb9595d4
commit 557b3f18d1
2 changed files with 37 additions and 0 deletions

View File

@ -557,4 +557,27 @@ HasValidGuidStringPrefix (
IN CONST CHAR16 *String
);
/**
Compares two Null-terminated Unocide and ASCII strings, and returns the
difference between the first mismatched characters.
This function compares the Null-terminated Unicode string FirstString to the
Null-terminated ASCII string SecondString. If FirstString is identical to
SecondString, then 0 is returned. Otherwise, the value returned is the first
mismatched character in SecondString subtracted from the first mismatched
character in FirstString.
@param FirstString A pointer to a Null-terminated Unicode string.
@param SecondString A pointer to a Null-terminated ASCII string.
@retval ==0 FirstString is identical to SecondString.
@retval !=0 FirstString is not identical to SecondString.
**/
INTN
MixedStrCmp (
IN CONST CHAR16 *FirstString,
IN CONST CHAR8 *SecondString
);
#endif // OC_STRING_LIB_H

View File

@ -405,3 +405,17 @@ HasValidGuidStringPrefix (
return TRUE;
}
INTN
MixedStrCmp (
IN CONST CHAR16 *FirstString,
IN CONST CHAR8 *SecondString
)
{
while (*FirstString != '\0' && *FirstString == *SecondString) {
++FirstString;
++SecondString;
}
return *FirstString - *SecondString;
}