|
|
|
@@ -1,7 +1,7 @@
|
|
|
|
|
/** @file
|
|
|
|
|
Unicode and ASCII string primatives.
|
|
|
|
|
|
|
|
|
|
Copyright (c) 2006 - 2007, Intel Corporation<BR>
|
|
|
|
|
Copyright (c) 2006 - 2008, Intel Corporation<BR>
|
|
|
|
|
All rights reserved. This program and the accompanying materials
|
|
|
|
|
are licensed and made available under the terms and conditions of the BSD License
|
|
|
|
|
which accompanies this distribution. The full text of the license may be found at
|
|
|
|
@@ -17,6 +17,18 @@
|
|
|
|
|
|
|
|
|
|
#include "BaseLibInternals.h"
|
|
|
|
|
|
|
|
|
|
#define QUOTIENT_MAX_UINTN_DIVIDED_BY_10 ((UINTN) -1 / 10)
|
|
|
|
|
#define REMAINDER_MAX_UINTN_DIVIDED_BY_10 ((UINTN) -1 % 10)
|
|
|
|
|
|
|
|
|
|
#define QUOTIENT_MAX_UINTN_DIVIDED_BY_16 ((UINTN) -1 / 16)
|
|
|
|
|
#define REMAINDER_MAX_UINTN_DIVIDED_BY_16 ((UINTN) -1 % 16)
|
|
|
|
|
|
|
|
|
|
#define QUOTIENT_MAX_UINT64_DIVIDED_BY_10 ((UINT64) -1 / 10)
|
|
|
|
|
#define REMAINDER_MAX_UINT64_DIVIDED_BY_10 ((UINT64) -1 % 10)
|
|
|
|
|
|
|
|
|
|
#define QUOTIENT_MAX_UINT64_DIVIDED_BY_16 ((UINT64) -1 / 16)
|
|
|
|
|
#define REMAINDER_MAX_UINT64_DIVIDED_BY_16 ((UINT64) -1 % 16)
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Copies one Null-terminated Unicode string to another Null-terminated Unicode
|
|
|
|
|
string and returns the new Unicode string.
|
|
|
|
@@ -37,7 +49,7 @@
|
|
|
|
|
@param Destination Pointer to a Null-terminated Unicode string.
|
|
|
|
|
@param Source Pointer to a Null-terminated Unicode string.
|
|
|
|
|
|
|
|
|
|
@return Destiantion
|
|
|
|
|
@return Destination pointing to the copied string.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
CHAR16 *
|
|
|
|
@@ -53,7 +65,7 @@ StrCpy (
|
|
|
|
|
// Destination cannot be NULL
|
|
|
|
|
//
|
|
|
|
|
ASSERT (Destination != NULL);
|
|
|
|
|
ASSERT (((UINTN) Destination & 0x01) == 0);
|
|
|
|
|
ASSERT (((UINTN) Destination & BIT0) == 0);
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Destination and source cannot overlap
|
|
|
|
@@ -95,7 +107,7 @@ StrCpy (
|
|
|
|
|
@param Source Pointer to a Null-terminated Unicode string.
|
|
|
|
|
@param Length Maximum number of Unicode characters to copy.
|
|
|
|
|
|
|
|
|
|
@return Destination
|
|
|
|
|
@return Destination pointing to the copied string.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
CHAR16 *
|
|
|
|
@@ -116,11 +128,10 @@ StrnCpy (
|
|
|
|
|
// Destination cannot be NULL if Length is not zero
|
|
|
|
|
//
|
|
|
|
|
ASSERT (Destination != NULL);
|
|
|
|
|
ASSERT (((UINTN) Destination & 0x01) == 0);
|
|
|
|
|
ASSERT (((UINTN) Destination & BIT0) == 0);
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Destination and source cannot overlap
|
|
|
|
|
// Q: Does Source have to be NULL-terminated?
|
|
|
|
|
//
|
|
|
|
|
ASSERT ((UINTN)(Destination - Source) > StrLen (Source));
|
|
|
|
|
ASSERT ((UINTN)(Source - Destination) >= Length);
|
|
|
|
@@ -162,7 +173,7 @@ StrLen (
|
|
|
|
|
UINTN Length;
|
|
|
|
|
|
|
|
|
|
ASSERT (String != NULL);
|
|
|
|
|
ASSERT (((UINTN) String & 0x01) == 0);
|
|
|
|
|
ASSERT (((UINTN) String & BIT0) == 0);
|
|
|
|
|
|
|
|
|
|
for (Length = 0; *String != L'\0'; String++, Length++) {
|
|
|
|
|
//
|
|
|
|
@@ -228,7 +239,8 @@ StrSize (
|
|
|
|
|
@param SecondString Pointer to a Null-terminated Unicode string.
|
|
|
|
|
|
|
|
|
|
@retval 0 FirstString is identical to SecondString.
|
|
|
|
|
@return others FirstString is not identical to SecondString.
|
|
|
|
|
@return The first mismatched Unicode character in SecondString subtracted
|
|
|
|
|
from the first mismatched Unicode character in FirstString.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
INTN
|
|
|
|
@@ -278,7 +290,8 @@ StrCmp (
|
|
|
|
|
@param Length Maximum number of Unicode characters to compare.
|
|
|
|
|
|
|
|
|
|
@retval 0 FirstString is identical to SecondString.
|
|
|
|
|
@return others FirstString is not identical to SecondString.
|
|
|
|
|
@return The value returned is the first mismatched Unicode character in SecondString
|
|
|
|
|
subtracted from the first mismatched Unicode character in FirstString.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
INTN
|
|
|
|
@@ -338,7 +351,7 @@ StrnCmp (
|
|
|
|
|
@param Destination Pointer to a Null-terminated Unicode string.
|
|
|
|
|
@param Source Pointer to a Null-terminated Unicode string.
|
|
|
|
|
|
|
|
|
|
@return Destination
|
|
|
|
|
@return Destination pointing to the concatenated Unicode string.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
CHAR16 *
|
|
|
|
@@ -392,7 +405,7 @@ StrCat (
|
|
|
|
|
@param Length Maximum number of Unicode characters to concatenate from
|
|
|
|
|
Source.
|
|
|
|
|
|
|
|
|
|
@return Destination
|
|
|
|
|
@return Destination pointing to the concatenated Unicode string.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
CHAR16 *
|
|
|
|
@@ -436,7 +449,7 @@ StrnCat (
|
|
|
|
|
@param SearchString Pointer to a Null-terminated Unicode string to search for.
|
|
|
|
|
|
|
|
|
|
@retval NULL If the SearchString does not appear in String.
|
|
|
|
|
@return others If there is a match.
|
|
|
|
|
@return Pointer to the matching sub-string.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
CHAR16 *
|
|
|
|
@@ -495,7 +508,7 @@ StrStr (
|
|
|
|
|
@param Char The character to check against.
|
|
|
|
|
|
|
|
|
|
@retval TRUE If the Char is a decmial character.
|
|
|
|
|
@retval FALSE Otherwise.
|
|
|
|
|
@retval FALSE If the Char is not a decmial character.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
BOOLEAN
|
|
|
|
@@ -512,7 +525,7 @@ InternalIsDecimalDigitCharacter (
|
|
|
|
|
it maps to a valid small-case ASCII character.
|
|
|
|
|
|
|
|
|
|
This internal function only deal with Unicode character
|
|
|
|
|
which maps to a valid small-case ASII character, i.e.
|
|
|
|
|
which maps to a valid small-case ASCII character, i.e.
|
|
|
|
|
L'a' to L'z'. For other Unicode character, the input character
|
|
|
|
|
is returned directly.
|
|
|
|
|
|
|
|
|
@@ -546,7 +559,7 @@ InternalCharToUpper (
|
|
|
|
|
|
|
|
|
|
@param Char The character to convert.
|
|
|
|
|
|
|
|
|
|
@retval UINTN The numerical value converted.
|
|
|
|
|
@return The numerical value converted.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
UINTN
|
|
|
|
@@ -573,7 +586,7 @@ InternalHexCharToUintn (
|
|
|
|
|
@param Char The character to check against.
|
|
|
|
|
|
|
|
|
|
@retval TRUE If the Char is a hexadecmial character.
|
|
|
|
|
@retval FALSE Otherwise.
|
|
|
|
|
@retval FALSE If the Char is not a hexadecmial character.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
BOOLEAN
|
|
|
|
@@ -619,7 +632,7 @@ InternalIsHexaDecimalDigitCharacter (
|
|
|
|
|
|
|
|
|
|
@param String Pointer to a Null-terminated Unicode string.
|
|
|
|
|
|
|
|
|
|
@retval UINTN
|
|
|
|
|
@return The value of type UINTN converted.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
UINTN
|
|
|
|
@@ -657,9 +670,9 @@ StrDecimalToUintn (
|
|
|
|
|
// If the number represented by String overflows according
|
|
|
|
|
// to the range defined by UINTN, then ASSERT().
|
|
|
|
|
//
|
|
|
|
|
ASSERT ((Result < QUIENT_MAX_UINTN_DIVIDED_BY_10) ||
|
|
|
|
|
((QUIENT_MAX_UINTN_DIVIDED_BY_10 == Result) &&
|
|
|
|
|
(*String - L'0') <= REMINDER_MAX_UINTN_DIVIDED_BY_10)
|
|
|
|
|
ASSERT ((Result < QUOTIENT_MAX_UINTN_DIVIDED_BY_10) ||
|
|
|
|
|
((QUOTIENT_MAX_UINTN_DIVIDED_BY_10 == Result) &&
|
|
|
|
|
(*String - L'0') <= REMAINDER_MAX_UINTN_DIVIDED_BY_10)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Result = Result * 10 + (*String - L'0');
|
|
|
|
@@ -701,7 +714,7 @@ StrDecimalToUintn (
|
|
|
|
|
|
|
|
|
|
@param String Pointer to a Null-terminated Unicode string.
|
|
|
|
|
|
|
|
|
|
@retval UINT64
|
|
|
|
|
@return The value of type UINT64 converted.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
UINT64
|
|
|
|
@@ -739,9 +752,9 @@ StrDecimalToUint64 (
|
|
|
|
|
// If the number represented by String overflows according
|
|
|
|
|
// to the range defined by UINTN, then ASSERT().
|
|
|
|
|
//
|
|
|
|
|
ASSERT ((Result < QUIENT_MAX_UINT64_DIVIDED_BY_10) ||
|
|
|
|
|
((QUIENT_MAX_UINT64_DIVIDED_BY_10 == Result) &&
|
|
|
|
|
(*String - L'0') <= REMINDER_MAX_UINT64_DIVIDED_BY_10)
|
|
|
|
|
ASSERT ((Result < QUOTIENT_MAX_UINT64_DIVIDED_BY_10) ||
|
|
|
|
|
((QUOTIENT_MAX_UINT64_DIVIDED_BY_10 == Result) &&
|
|
|
|
|
(*String - L'0') <= REMAINDER_MAX_UINT64_DIVIDED_BY_10)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Result = MultU64x32 (Result, 10) + (*String - L'0');
|
|
|
|
@@ -783,7 +796,7 @@ StrDecimalToUint64 (
|
|
|
|
|
|
|
|
|
|
@param String Pointer to a Null-terminated Unicode string.
|
|
|
|
|
|
|
|
|
|
@retval UINTN
|
|
|
|
|
@return The value of type UINTN converted.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
UINTN
|
|
|
|
@@ -832,9 +845,9 @@ StrHexToUintn (
|
|
|
|
|
// If the Hex Number represented by String overflows according
|
|
|
|
|
// to the range defined by UINTN, then ASSERT().
|
|
|
|
|
//
|
|
|
|
|
ASSERT ((Result < QUIENT_MAX_UINTN_DIVIDED_BY_16) ||
|
|
|
|
|
((QUIENT_MAX_UINTN_DIVIDED_BY_16 == Result) &&
|
|
|
|
|
(InternalHexCharToUintn (*String) <= REMINDER_MAX_UINTN_DIVIDED_BY_16))
|
|
|
|
|
ASSERT ((Result < QUOTIENT_MAX_UINTN_DIVIDED_BY_16) ||
|
|
|
|
|
((QUOTIENT_MAX_UINTN_DIVIDED_BY_16 == Result) &&
|
|
|
|
|
(InternalHexCharToUintn (*String) <= REMAINDER_MAX_UINTN_DIVIDED_BY_16))
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Result = (Result << 4) + InternalHexCharToUintn (*String);
|
|
|
|
@@ -877,7 +890,7 @@ StrHexToUintn (
|
|
|
|
|
|
|
|
|
|
@param String Pointer to a Null-terminated Unicode string.
|
|
|
|
|
|
|
|
|
|
@retval UINT64
|
|
|
|
|
@return The value of type UINT64 converted.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
UINT64
|
|
|
|
@@ -926,9 +939,9 @@ StrHexToUint64 (
|
|
|
|
|
// If the Hex Number represented by String overflows according
|
|
|
|
|
// to the range defined by UINTN, then ASSERT().
|
|
|
|
|
//
|
|
|
|
|
ASSERT ((Result < QUIENT_MAX_UINT64_DIVIDED_BY_16)||
|
|
|
|
|
((QUIENT_MAX_UINT64_DIVIDED_BY_16 == Result) &&
|
|
|
|
|
(InternalHexCharToUintn (*String) <= REMINDER_MAX_UINT64_DIVIDED_BY_16))
|
|
|
|
|
ASSERT ((Result < QUOTIENT_MAX_UINT64_DIVIDED_BY_16)||
|
|
|
|
|
((QUOTIENT_MAX_UINT64_DIVIDED_BY_16 == Result) &&
|
|
|
|
|
(InternalHexCharToUintn (*String) <= REMAINDER_MAX_UINT64_DIVIDED_BY_16))
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Result = LShiftU64 (Result, 4);
|
|
|
|
@@ -949,7 +962,7 @@ StrHexToUint64 (
|
|
|
|
|
@param Char The character to check against.
|
|
|
|
|
|
|
|
|
|
@retval TRUE If the Char is a decmial character.
|
|
|
|
|
@retval FALSE Otherwise.
|
|
|
|
|
@retval FALSE If the Char is not a decmial character.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
BOOLEAN
|
|
|
|
@@ -972,7 +985,7 @@ InternalAsciiIsDecimalDigitCharacter (
|
|
|
|
|
@param Char The character to check against.
|
|
|
|
|
|
|
|
|
|
@retval TRUE If the Char is a hexadecmial character.
|
|
|
|
|
@retval FALSE Otherwise.
|
|
|
|
|
@retval FALSE If the Char is not a hexadecmial character.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
BOOLEAN
|
|
|
|
@@ -1017,7 +1030,7 @@ InternalAsciiIsHexaDecimalDigitCharacter (
|
|
|
|
|
@param Source Pointer to a Null-terminated Unicode string.
|
|
|
|
|
@param Destination Pointer to a Null-terminated ASCII string.
|
|
|
|
|
|
|
|
|
|
@return Destination
|
|
|
|
|
@return Destination pointing to the converted ASCII string.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
CHAR8 *
|
|
|
|
@@ -1084,7 +1097,7 @@ UnicodeStrToAsciiStr (
|
|
|
|
|
@param Destination Pointer to a Null-terminated ASCII string.
|
|
|
|
|
@param Source Pointer to a Null-terminated ASCII string.
|
|
|
|
|
|
|
|
|
|
@return Destination
|
|
|
|
|
@return Destination pointing to the copied string.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
CHAR8 *
|
|
|
|
@@ -1138,7 +1151,7 @@ AsciiStrCpy (
|
|
|
|
|
@param Source Pointer to a Null-terminated ASCII string.
|
|
|
|
|
@param Length Maximum number of ASCII characters to copy.
|
|
|
|
|
|
|
|
|
|
@return Destination
|
|
|
|
|
@return Destination pointing to the copied string.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
CHAR8 *
|
|
|
|
@@ -1264,7 +1277,8 @@ AsciiStrSize (
|
|
|
|
|
@param SecondString Pointer to a Null-terminated ASCII string.
|
|
|
|
|
|
|
|
|
|
@retval 0 FirstString is identical to SecondString.
|
|
|
|
|
@return others FirstString is not identical to SecondString.
|
|
|
|
|
@return The first mismatched ASCII character in SecondString subtracted
|
|
|
|
|
from the first mismatched ASCII character in FirstString.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
INTN
|
|
|
|
@@ -1289,7 +1303,7 @@ AsciiStrCmp (
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Converts a lowercase Ascii character to upper one
|
|
|
|
|
Converts a lowercase Ascii character to upper one.
|
|
|
|
|
|
|
|
|
|
If Chr is lowercase Ascii character, then converts it to upper one.
|
|
|
|
|
|
|
|
|
@@ -1320,7 +1334,7 @@ AsciiToUpper (
|
|
|
|
|
|
|
|
|
|
@param Char The character to convert.
|
|
|
|
|
|
|
|
|
|
@retval UINTN The numerical value converted.
|
|
|
|
|
@return The numerical value converted.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
UINTN
|
|
|
|
@@ -1362,8 +1376,8 @@ InternalAsciiHexCharToUintn (
|
|
|
|
|
|
|
|
|
|
@retval 0 FirstString is identical to SecondString using case insensitive
|
|
|
|
|
comparisons.
|
|
|
|
|
@return others FirstString is not identical to SecondString using case
|
|
|
|
|
insensitive comparisons.
|
|
|
|
|
@return The first mismatched lower case ASCII character in SecondString subtracted
|
|
|
|
|
from the first mismatched lower case ASCII character in FirstString.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
INTN
|
|
|
|
@@ -1419,7 +1433,8 @@ AsciiStriCmp (
|
|
|
|
|
@param Length Maximum number of ASCII characters to compare.
|
|
|
|
|
|
|
|
|
|
@retval 0 FirstString is identical to SecondString.
|
|
|
|
|
@return others FirstString is not identical to SecondString.
|
|
|
|
|
@return The first mismatched ASCII character in SecondString subtracted from the
|
|
|
|
|
first mismatched ASCII character in FirstString.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
INTN
|
|
|
|
@@ -1474,7 +1489,7 @@ AsciiStrnCmp (
|
|
|
|
|
@param Destination Pointer to a Null-terminated ASCII string.
|
|
|
|
|
@param Source Pointer to a Null-terminated ASCII string.
|
|
|
|
|
|
|
|
|
|
@return Destination
|
|
|
|
|
@return Destination pointing to the concatenated ASCII string.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
CHAR8 *
|
|
|
|
@@ -1525,7 +1540,7 @@ AsciiStrCat (
|
|
|
|
|
@param Length Maximum number of ASCII characters to concatenate from
|
|
|
|
|
Source.
|
|
|
|
|
|
|
|
|
|
@return Destination
|
|
|
|
|
@return Destination pointing to the concatenated ASCII string.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
CHAR8 *
|
|
|
|
@@ -1566,7 +1581,7 @@ AsciiStrnCat (
|
|
|
|
|
@param SearchString Pointer to a Null-terminated ASCII string to search for.
|
|
|
|
|
|
|
|
|
|
@retval NULL If the SearchString does not appear in String.
|
|
|
|
|
@return others If there is a match.
|
|
|
|
|
@return Pointer to the matching sub-string.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
CHAR8 *
|
|
|
|
@@ -1641,7 +1656,7 @@ AsciiStrStr (
|
|
|
|
|
|
|
|
|
|
@param String Pointer to a Null-terminated ASCII string.
|
|
|
|
|
|
|
|
|
|
@retval UINTN
|
|
|
|
|
@return The value of type UINTN converted.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
UINTN
|
|
|
|
@@ -1678,9 +1693,9 @@ AsciiStrDecimalToUintn (
|
|
|
|
|
// If the number represented by String overflows according
|
|
|
|
|
// to the range defined by UINTN, then ASSERT().
|
|
|
|
|
//
|
|
|
|
|
ASSERT ((Result < QUIENT_MAX_UINTN_DIVIDED_BY_10) ||
|
|
|
|
|
((QUIENT_MAX_UINTN_DIVIDED_BY_10 == Result) &&
|
|
|
|
|
(*String - '0') <= REMINDER_MAX_UINTN_DIVIDED_BY_10)
|
|
|
|
|
ASSERT ((Result < QUOTIENT_MAX_UINTN_DIVIDED_BY_10) ||
|
|
|
|
|
((QUOTIENT_MAX_UINTN_DIVIDED_BY_10 == Result) &&
|
|
|
|
|
(*String - '0') <= REMAINDER_MAX_UINTN_DIVIDED_BY_10)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Result = Result * 10 + (*String - '0');
|
|
|
|
@@ -1718,7 +1733,7 @@ AsciiStrDecimalToUintn (
|
|
|
|
|
|
|
|
|
|
@param String Pointer to a Null-terminated ASCII string.
|
|
|
|
|
|
|
|
|
|
@retval UINT64
|
|
|
|
|
@return The value of type UINT64 converted.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
UINT64
|
|
|
|
@@ -1755,9 +1770,9 @@ AsciiStrDecimalToUint64 (
|
|
|
|
|
// If the number represented by String overflows according
|
|
|
|
|
// to the range defined by UINTN, then ASSERT().
|
|
|
|
|
//
|
|
|
|
|
ASSERT ((Result < QUIENT_MAX_UINT64_DIVIDED_BY_10) ||
|
|
|
|
|
((QUIENT_MAX_UINT64_DIVIDED_BY_10 == Result) &&
|
|
|
|
|
(*String - '0') <= REMINDER_MAX_UINT64_DIVIDED_BY_10)
|
|
|
|
|
ASSERT ((Result < QUOTIENT_MAX_UINT64_DIVIDED_BY_10) ||
|
|
|
|
|
((QUOTIENT_MAX_UINT64_DIVIDED_BY_10 == Result) &&
|
|
|
|
|
(*String - '0') <= REMAINDER_MAX_UINT64_DIVIDED_BY_10)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Result = MultU64x32 (Result, 10) + (*String - '0');
|
|
|
|
@@ -1798,7 +1813,7 @@ AsciiStrDecimalToUint64 (
|
|
|
|
|
|
|
|
|
|
@param String Pointer to a Null-terminated ASCII string.
|
|
|
|
|
|
|
|
|
|
@retval UINTN
|
|
|
|
|
@return The value of type UINTN converted.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
UINTN
|
|
|
|
@@ -1846,9 +1861,9 @@ AsciiStrHexToUintn (
|
|
|
|
|
// If the Hex Number represented by String overflows according
|
|
|
|
|
// to the range defined by UINTN, then ASSERT().
|
|
|
|
|
//
|
|
|
|
|
ASSERT ((Result < QUIENT_MAX_UINTN_DIVIDED_BY_16) ||
|
|
|
|
|
((QUIENT_MAX_UINTN_DIVIDED_BY_16 == Result) &&
|
|
|
|
|
(InternalAsciiHexCharToUintn (*String) <= REMINDER_MAX_UINTN_DIVIDED_BY_16))
|
|
|
|
|
ASSERT ((Result < QUOTIENT_MAX_UINTN_DIVIDED_BY_16) ||
|
|
|
|
|
((QUOTIENT_MAX_UINTN_DIVIDED_BY_16 == Result) &&
|
|
|
|
|
(InternalAsciiHexCharToUintn (*String) <= REMAINDER_MAX_UINTN_DIVIDED_BY_16))
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Result = (Result << 4) + InternalAsciiHexCharToUintn (*String);
|
|
|
|
@@ -1890,7 +1905,7 @@ AsciiStrHexToUintn (
|
|
|
|
|
|
|
|
|
|
@param String Pointer to a Null-terminated ASCII string.
|
|
|
|
|
|
|
|
|
|
@retval UINT64
|
|
|
|
|
@return The value of type UINT64 converted.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
UINT64
|
|
|
|
@@ -1941,9 +1956,9 @@ AsciiStrHexToUint64 (
|
|
|
|
|
// If the Hex Number represented by String overflows according
|
|
|
|
|
// to the range defined by UINTN, then ASSERT().
|
|
|
|
|
//
|
|
|
|
|
ASSERT ((Result < QUIENT_MAX_UINT64_DIVIDED_BY_16) ||
|
|
|
|
|
((QUIENT_MAX_UINT64_DIVIDED_BY_16 == Result) &&
|
|
|
|
|
(InternalAsciiHexCharToUintn (*String) <= REMINDER_MAX_UINT64_DIVIDED_BY_16))
|
|
|
|
|
ASSERT ((Result < QUOTIENT_MAX_UINT64_DIVIDED_BY_16) ||
|
|
|
|
|
((QUOTIENT_MAX_UINT64_DIVIDED_BY_16 == Result) &&
|
|
|
|
|
(InternalAsciiHexCharToUintn (*String) <= REMAINDER_MAX_UINT64_DIVIDED_BY_16))
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Result = LShiftU64 (Result, 4);
|
|
|
|
@@ -1979,7 +1994,7 @@ AsciiStrHexToUint64 (
|
|
|
|
|
@param Source Pointer to a Null-terminated ASCII string.
|
|
|
|
|
@param Destination Pointer to a Null-terminated Unicode string.
|
|
|
|
|
|
|
|
|
|
@return Destination
|
|
|
|
|
@return Destination pointing to the converted Unicode string.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
CHAR16 *
|
|
|
|
@@ -2032,7 +2047,7 @@ AsciiStrToUnicodeStr (
|
|
|
|
|
|
|
|
|
|
@param Value The 8-bit value to convert to BCD. Range 0..99.
|
|
|
|
|
|
|
|
|
|
@return The BCD value
|
|
|
|
|
@return The BCD value converted.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
UINT8
|
|
|
|
@@ -2056,7 +2071,7 @@ DecimalToBcd8 (
|
|
|
|
|
|
|
|
|
|
@param Value The 8-bit BCD value to convert to an 8-bit value.
|
|
|
|
|
|
|
|
|
|
@return The 8-bit value is returned.
|
|
|
|
|
@return The 8-bit decimal value converted.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
UINT8
|
|
|
|
@@ -2082,7 +2097,7 @@ BcdToDecimal8 (
|
|
|
|
|
|
|
|
|
|
@param Nibble The nibble which is in the low 4 bits of the input byte.
|
|
|
|
|
|
|
|
|
|
@retval CHAR16 The Unicode hexadecimal character.
|
|
|
|
|
@return The Unicode hexadecimal character.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
CHAR16
|
|
|
|
@@ -2113,14 +2128,13 @@ NibbleToHexChar (
|
|
|
|
|
the input buffer for a 64-bits unsigned integrer 0x12345678abcdef1234 will be converted to
|
|
|
|
|
a Unicode string equal to L"12345678abcdef1234".
|
|
|
|
|
|
|
|
|
|
@param String On input, String is pointed to the buffer allocated for the convertion.
|
|
|
|
|
@param StringLen The Length of String buffer to hold the output String. The length must include the tailing '\0' character.
|
|
|
|
|
The StringLen required to convert a N bytes Buffer will be a least equal to or greater
|
|
|
|
|
than 2*N + 1.
|
|
|
|
|
@param String Pointer to the buffer allocated for the convertion.
|
|
|
|
|
@param StringLen On input: Pointer to length in bytes of buffer to hold the Unicode string.
|
|
|
|
|
On output:If return EFI_SUCCESS, pointer to length of Unicode string converted.
|
|
|
|
|
If return EFI_BUFFER_TOO_SMALL, pointer to length of string buffer desired.
|
|
|
|
|
@param Buffer The pointer to a input buffer.
|
|
|
|
|
@param BufferSizeInBytes Lenth in bytes of the input buffer.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The convertion is successfull. All bytes in Buffer has been convert to the corresponding
|
|
|
|
|
Unicode character and placed into the right place in String.
|
|
|
|
|
@retval EFI_BUFFER_TOO_SMALL StringSizeInBytes is smaller than 2 * N + 1the number of bytes required to
|
|
|
|
@@ -2275,10 +2289,9 @@ HexStringToBuf (
|
|
|
|
|
Unicode character is converted to a byte. For example, Unicode character
|
|
|
|
|
L'A' will be converted to 0x0A.
|
|
|
|
|
|
|
|
|
|
If Digit is NULL, then ASSERT.
|
|
|
|
|
If Digit is NULL, then ASSERT().
|
|
|
|
|
|
|
|
|
|
@param Digit The output hexadecimal digit.
|
|
|
|
|
|
|
|
|
|
@param Char The input Unicode character.
|
|
|
|
|
|
|
|
|
|
@retval TRUE Char is in the range of Hexadecimal number. Digit is updated
|
|
|
|
|