TianoCore EDK2 master
Loading...
Searching...
No Matches
String.c File Reference
#include "BaseLibInternals.h"

Go to the source code of this file.

Functions

UINTN EFIAPI StrLen (IN CONST CHAR16 *String)
 
UINTN EFIAPI StrSize (IN CONST CHAR16 *String)
 
INTN EFIAPI StrCmp (IN CONST CHAR16 *FirstString, IN CONST CHAR16 *SecondString)
 
INTN EFIAPI StrnCmp (IN CONST CHAR16 *FirstString, IN CONST CHAR16 *SecondString, IN UINTN Length)
 
CHAR16 *EFIAPI StrStr (IN CONST CHAR16 *String, IN CONST CHAR16 *SearchString)
 
BOOLEAN EFIAPI InternalIsDecimalDigitCharacter (IN CHAR16 Char)
 
CHAR16 EFIAPI CharToUpper (IN CHAR16 Char)
 
UINTN EFIAPI InternalHexCharToUintn (IN CHAR16 Char)
 
BOOLEAN EFIAPI InternalIsHexaDecimalDigitCharacter (IN CHAR16 Char)
 
UINTN EFIAPI StrDecimalToUintn (IN CONST CHAR16 *String)
 
UINT64 EFIAPI StrDecimalToUint64 (IN CONST CHAR16 *String)
 
UINTN EFIAPI StrHexToUintn (IN CONST CHAR16 *String)
 
UINT64 EFIAPI StrHexToUint64 (IN CONST CHAR16 *String)
 
BOOLEAN EFIAPI InternalAsciiIsDecimalDigitCharacter (IN CHAR8 Char)
 
BOOLEAN EFIAPI InternalAsciiIsHexaDecimalDigitCharacter (IN CHAR8 Char)
 
UINTN EFIAPI AsciiStrLen (IN CONST CHAR8 *String)
 
UINTN EFIAPI AsciiStrSize (IN CONST CHAR8 *String)
 
INTN EFIAPI AsciiStrCmp (IN CONST CHAR8 *FirstString, IN CONST CHAR8 *SecondString)
 
CHAR8 EFIAPI AsciiCharToUpper (IN CHAR8 Chr)
 
UINTN EFIAPI InternalAsciiHexCharToUintn (IN CHAR8 Char)
 
INTN EFIAPI AsciiStriCmp (IN CONST CHAR8 *FirstString, IN CONST CHAR8 *SecondString)
 
INTN EFIAPI AsciiStrnCmp (IN CONST CHAR8 *FirstString, IN CONST CHAR8 *SecondString, IN UINTN Length)
 
CHAR8 *EFIAPI AsciiStrStr (IN CONST CHAR8 *String, IN CONST CHAR8 *SearchString)
 
UINTN EFIAPI AsciiStrDecimalToUintn (IN CONST CHAR8 *String)
 
UINT64 EFIAPI AsciiStrDecimalToUint64 (IN CONST CHAR8 *String)
 
UINTN EFIAPI AsciiStrHexToUintn (IN CONST CHAR8 *String)
 
UINT64 EFIAPI AsciiStrHexToUint64 (IN CONST CHAR8 *String)
 
RETURN_STATUS EFIAPI Base64Encode (IN CONST UINT8 *Source, IN UINTN SourceLength, OUT CHAR8 *Destination OPTIONAL, IN OUT UINTN *DestinationSize)
 
RETURN_STATUS EFIAPI Base64Decode (IN CONST CHAR8 *Source OPTIONAL, IN UINTN SourceSize, OUT UINT8 *Destination OPTIONAL, IN OUT UINTN *DestinationSize)
 
UINT8 EFIAPI DecimalToBcd8 (IN UINT8 Value)
 
UINT8 EFIAPI BcdToDecimal8 (IN UINT8 Value)
 

Variables

STATIC CHAR8 EncodingTable []
 

Detailed Description

Unicode and ASCII string primitives.

Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file String.c.

Function Documentation

◆ AsciiCharToUpper()

CHAR8 EFIAPI AsciiCharToUpper ( IN CHAR8  Chr)

Converts a lowercase Ascii character to upper one.

If Chr is lowercase Ascii character, then converts it to upper one.

If Value >= 0xA0, then ASSERT(). If (Value & 0x0F) >= 0x0A, then ASSERT().

Parameters
Chrone Ascii character
Returns
The uppercase value of Ascii character

Definition at line 750 of file String.c.

◆ AsciiStrCmp()

INTN EFIAPI AsciiStrCmp ( IN CONST CHAR8 *  FirstString,
IN CONST CHAR8 *  SecondString 
)

Compares two Null-terminated ASCII strings, and returns the difference between the first mismatched ASCII characters.

This function compares the Null-terminated ASCII 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 ASCII character in SecondString subtracted from the first mismatched ASCII character in FirstString.

If FirstString is NULL, then ASSERT(). If SecondString is NULL, then ASSERT(). If PcdMaximumAsciiStringLength is not zero and FirstString contains more than PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator, then ASSERT(). If PcdMaximumAsciiStringLength is not zero and SecondString contains more than PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator, then ASSERT().

Parameters
FirstStringA pointer to a Null-terminated ASCII string.
SecondStringA pointer to a Null-terminated ASCII string.
Return values
==0FirstString is identical to SecondString.
!=0FirstString is not identical to SecondString.

Definition at line 716 of file String.c.

◆ AsciiStrDecimalToUint64()

UINT64 EFIAPI AsciiStrDecimalToUint64 ( IN CONST CHAR8 *  String)

Convert a Null-terminated ASCII decimal string to a value of type UINT64.

This function returns a value of type UINT64 by interpreting the contents of the ASCII string String as a decimal number. The format of the input ASCII string String is:

              [spaces] [decimal digits].

The valid decimal digit character is in the range [0-9]. The function will ignore the pad space, which includes spaces or tab characters, before the digits. The running zero in the beginning of [decimal digits] will be ignored. Then, the function stops at the first character that is a not a valid decimal character or Null-terminator, whichever on comes first.

If String has only pad spaces, then 0 is returned. If String has no pad spaces or valid decimal digits, then 0 is returned. If the number represented by String overflows according to the range defined by UINT64, then MAX_UINT64 is returned. If String is NULL, then ASSERT(). If PcdMaximumAsciiStringLength is not zero, and String contains more than PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then ASSERT().

Parameters
StringA pointer to a Null-terminated ASCII string.
Return values
Valuetranslated from String.

Definition at line 1053 of file String.c.

◆ AsciiStrDecimalToUintn()

UINTN EFIAPI AsciiStrDecimalToUintn ( IN CONST CHAR8 *  String)

Convert a Null-terminated ASCII decimal string to a value of type UINTN.

This function returns a value of type UINTN by interpreting the contents of the ASCII string String as a decimal number. The format of the input ASCII string String is:

              [spaces] [decimal digits].

The valid decimal digit character is in the range [0-9]. The function will ignore the pad space, which includes spaces or tab characters, before the digits. The running zero in the beginning of [decimal digits] will be ignored. Then, the function stops at the first character that is a not a valid decimal character or Null-terminator, whichever on comes first.

If String has only pad spaces, then 0 is returned. If String has no pad spaces or valid decimal digits, then 0 is returned. If the number represented by String overflows according to the range defined by UINTN, then MAX_UINTN is returned. If String is NULL, then ASSERT(). If PcdMaximumAsciiStringLength is not zero, and String contains more than PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then ASSERT().

Parameters
StringA pointer to a Null-terminated ASCII string.
Return values
Valuetranslated from String.

Definition at line 1006 of file String.c.

◆ AsciiStrHexToUint64()

UINT64 EFIAPI AsciiStrHexToUint64 ( IN CONST CHAR8 *  String)

Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.

This function returns a value of type UINT64 by interpreting the contents of the ASCII string String as a hexadecimal number. The format of the input ASCII string String is:

            [spaces][zeros][x][hexadecimal digits].

The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F]. The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x" appears in the input string, it must be prefixed with at least one 0. The function will ignore the pad space, which includes spaces or tab characters, before [zeros], [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits] will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal digit. Then, the function stops at the first character that is a not a valid hexadecimal character or Null-terminator, whichever on comes first.

If String has only pad spaces, then 0 is returned. If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then 0 is returned.

If the number represented by String overflows according to the range defined by UINT64, then MAX_UINT64 is returned. If String is NULL, then ASSERT(). If PcdMaximumAsciiStringLength is not zero, and String contains more than PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then ASSERT().

Parameters
StringA pointer to a Null-terminated ASCII string.
Return values
Valuetranslated from String.

Definition at line 1155 of file String.c.

◆ AsciiStrHexToUintn()

UINTN EFIAPI AsciiStrHexToUintn ( IN CONST CHAR8 *  String)

Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.

This function returns a value of type UINTN by interpreting the contents of the ASCII string String as a hexadecimal number. The format of the input ASCII string String is:

            [spaces][zeros][x][hexadecimal digits].

The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F]. The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x" appears in the input string, it must be prefixed with at least one 0. The function will ignore the pad space, which includes spaces or tab characters, before [zeros], [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits] will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal digit. Then, the function stops at the first character that is a not a valid hexadecimal character or Null-terminator, whichever on comes first.

If String has only pad spaces, then 0 is returned. If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then 0 is returned.

If the number represented by String overflows according to the range defined by UINTN, then MAX_UINTN is returned. If String is NULL, then ASSERT(). If PcdMaximumAsciiStringLength is not zero, and String contains more than PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then ASSERT().

Parameters
StringA pointer to a Null-terminated ASCII string.
Return values
Valuetranslated from String.

Definition at line 1104 of file String.c.

◆ AsciiStriCmp()

INTN EFIAPI AsciiStriCmp ( IN CONST CHAR8 *  FirstString,
IN CONST CHAR8 *  SecondString 
)

Performs a case insensitive comparison of two Null-terminated ASCII strings, and returns the difference between the first mismatched ASCII characters.

This function performs a case insensitive comparison of the Null-terminated ASCII 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 lower case ASCII character in SecondString subtracted from the first mismatched lower case ASCII character in FirstString.

If FirstString is NULL, then ASSERT(). If SecondString is NULL, then ASSERT(). If PcdMaximumAsciiStringLength is not zero and FirstString contains more than PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator, then ASSERT(). If PcdMaximumAsciiStringLength is not zero and SecondString contains more than PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator, then ASSERT().

Parameters
FirstStringA pointer to a Null-terminated ASCII string.
SecondStringA pointer to a Null-terminated ASCII string.
Return values
==0FirstString is identical to SecondString using case insensitive comparisons.
!=0FirstString is not identical to SecondString using case insensitive comparisons.

Definition at line 814 of file String.c.

◆ AsciiStrLen()

UINTN EFIAPI AsciiStrLen ( IN CONST CHAR8 *  String)

Returns the length of a Null-terminated ASCII string.

This function returns the number of ASCII characters in the Null-terminated ASCII string specified by String.

If Length > 0 and Destination is NULL, then ASSERT(). If Length > 0 and Source is NULL, then ASSERT(). If PcdMaximumAsciiStringLength is not zero and String contains more than PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator, then ASSERT().

Parameters
StringA pointer to a Null-terminated ASCII string.
Returns
The length of String.

Definition at line 641 of file String.c.

◆ AsciiStrnCmp()

INTN EFIAPI AsciiStrnCmp ( IN CONST CHAR8 *  FirstString,
IN CONST CHAR8 *  SecondString,
IN UINTN  Length 
)

Compares two Null-terminated ASCII strings with maximum lengths, and returns the difference between the first mismatched ASCII characters.

This function compares the Null-terminated ASCII string FirstString to the Null-terminated ASCII string SecondString. At most, Length ASCII characters will be compared. If Length is 0, then 0 is returned. If FirstString is identical to SecondString, then 0 is returned. Otherwise, the value returned is the first mismatched ASCII character in SecondString subtracted from the first mismatched ASCII character in FirstString.

If Length > 0 and FirstString is NULL, then ASSERT(). If Length > 0 and SecondString is NULL, then ASSERT(). If PcdMaximumAsciiStringLength is not zero, and Length is greater than PcdMaximumAsciiStringLength, then ASSERT(). If PcdMaximumAsciiStringLength is not zero, and FirstString contains more than PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator, then ASSERT(). If PcdMaximumAsciiStringLength is not zero, and SecondString contains more than PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator, then ASSERT().

Parameters
FirstStringA pointer to a Null-terminated ASCII string.
SecondStringA pointer to a Null-terminated ASCII string.
LengthThe maximum number of ASCII characters for compare.
Return values
==0FirstString is identical to SecondString.
!=0FirstString is not identical to SecondString.

Definition at line 872 of file String.c.

◆ AsciiStrSize()

UINTN EFIAPI AsciiStrSize ( IN CONST CHAR8 *  String)

Returns the size of a Null-terminated ASCII string in bytes, including the Null terminator.

This function returns the size, in bytes, of the Null-terminated ASCII string specified by String.

If String is NULL, then ASSERT(). If PcdMaximumAsciiStringLength is not zero and String contains more than PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator, then ASSERT().

Parameters
StringA pointer to a Null-terminated ASCII string.
Returns
The size of String.

Definition at line 681 of file String.c.

◆ AsciiStrStr()

CHAR8 *EFIAPI AsciiStrStr ( IN CONST CHAR8 *  String,
IN CONST CHAR8 *  SearchString 
)

Returns the first occurrence of a Null-terminated ASCII sub-string in a Null-terminated ASCII string.

This function scans the contents of the ASCII string specified by String and returns the first occurrence of SearchString. If SearchString is not found in String, then NULL is returned. If the length of SearchString is zero, then String is returned.

If String is NULL, then ASSERT(). If SearchString is NULL, then ASSERT().

If PcdMaximumAsciiStringLength is not zero, and SearchString or String contains more than PcdMaximumAsciiStringLength Unicode characters not including the Null-terminator, then ASSERT().

Parameters
StringA pointer to a Null-terminated ASCII string.
SearchStringA pointer to a Null-terminated ASCII string to search for.
Return values
NULLIf the SearchString does not appear in String.
othersIf there is a match return the first occurrence of SearchingString. If the length of SearchString is zero,return String.

Definition at line 931 of file String.c.

◆ Base64Decode()

RETURN_STATUS EFIAPI Base64Decode ( IN CONST CHAR8 *Source  OPTIONAL,
IN UINTN  SourceSize,
OUT UINT8 *Destination  OPTIONAL,
IN OUT UINTN DestinationSize 
)

Decode Base64 ASCII encoded data to 8-bit binary representation, based on RFC4648.

Decoding occurs according to "Table 1: The Base 64 Alphabet" in RFC4648.

Whitespace is ignored at all positions:

  • 0x09 ('\t') horizontal tab
  • 0x0A ('
    ') new line
  • 0x0B ('\v') vertical tab
  • 0x0C ('\f') form feed
  • 0x0D ('\r') carriage return
  • 0x20 (' ') space

The minimum amount of required padding (with ASCII 0x3D, '=') is tolerated and enforced at the end of the Base64 ASCII encoded data, and only there.

Other characters outside of the encoding alphabet cause the function to reject the Base64 ASCII encoded data.

Parameters
[in]SourceArray of CHAR8 elements containing the Base64 ASCII encoding. May be NULL if SourceSize is zero.
[in]SourceSizeNumber of CHAR8 elements in Source.
[out]DestinationArray of UINT8 elements receiving the decoded 8-bit binary representation. Allocated by the caller. May be NULL if DestinationSize is zero on input. If NULL, decoding is performed, but the 8-bit binary representation is not stored. If non-NULL and the function returns an error, the contents of Destination are indeterminate.
[in,out]DestinationSizeOn input, the number of UINT8 elements that the caller allocated for Destination. On output, if the function returns RETURN_SUCCESS or RETURN_BUFFER_TOO_SMALL, the number of UINT8 elements that are required for decoding the Base64 ASCII representation. If the function returns a value different from both RETURN_SUCCESS and RETURN_BUFFER_TOO_SMALL, then DestinationSize is indeterminate on output.
Return values
RETURN_SUCCESSSourceSize CHAR8 elements at Source have been decoded to on-output DestinationSize UINT8 elements at Destination. Note that RETURN_SUCCESS covers the case when DestinationSize is zero on input, and Source decodes to zero bytes (due to containing at most ignored whitespace).
RETURN_BUFFER_TOO_SMALLThe input value of DestinationSize is not large enough for decoding SourceSize CHAR8 elements at Source. The required number of UINT8 elements has been stored to DestinationSize.
RETURN_INVALID_PARAMETERDestinationSize is NULL.
RETURN_INVALID_PARAMETERSource is NULL, but SourceSize is not zero.
RETURN_INVALID_PARAMETERDestination is NULL, but DestinationSize is not zero on input.
RETURN_INVALID_PARAMETERSource is non-NULL, and (Source + SourceSize) would wrap around MAX_ADDRESS.
RETURN_INVALID_PARAMETERDestination is non-NULL, and (Destination + DestinationSize) would wrap around MAX_ADDRESS, as specified on input.
RETURN_INVALID_PARAMETERNone of Source and Destination are NULL, and CHAR8[SourceSize] at Source overlaps UINT8[DestinationSize] at Destination, as specified on input.
RETURN_INVALID_PARAMETERInvalid CHAR8 element encountered in Source.

Definition at line 1379 of file String.c.

◆ Base64Encode()

RETURN_STATUS EFIAPI Base64Encode ( IN CONST UINT8 *  Source,
IN UINTN  SourceLength,
OUT CHAR8 *Destination  OPTIONAL,
IN OUT UINTN DestinationSize 
)

Convert binary data to a Base64 encoded ascii string based on RFC4648.

Produce a Null-terminated Ascii string in the output buffer specified by Destination and DestinationSize. The Ascii string is produced by converting the data string specified by Source and SourceLength.

Parameters
SourceInput UINT8 data
SourceLengthNumber of UINT8 bytes of data
DestinationPointer to output string buffer
DestinationSizeSize of ascii buffer. Set to 0 to get the size needed. Caller is responsible for passing in buffer of DestinationSize
Return values
RETURN_SUCCESSWhen ascii buffer is filled in.
RETURN_INVALID_PARAMETERIf Source is NULL or DestinationSize is NULL.
RETURN_INVALID_PARAMETERIf SourceLength or DestinationSize is bigger than (MAX_ADDRESS - (UINTN)Destination).
RETURN_BUFFER_TOO_SMALLIf SourceLength is 0 and DestinationSize is <1.
RETURN_BUFFER_TOO_SMALLIf Destination is NULL or DestinationSize is smaller than required buffersize.

Definition at line 1195 of file String.c.

◆ BcdToDecimal8()

UINT8 EFIAPI BcdToDecimal8 ( IN UINT8  Value)

Converts an 8-bit BCD value to an 8-bit value.

Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit value is returned.

If Value >= 0xA0, then ASSERT(). If (Value & 0x0F) >= 0x0A, then ASSERT().

Parameters
ValueThe 8-bit BCD value to convert to an 8-bit value.
Returns
The 8-bit value is returned.

Definition at line 1677 of file String.c.

◆ CharToUpper()

CHAR16 EFIAPI CharToUpper ( IN CHAR16  Char)

Convert a Unicode character to upper case only if it maps to a valid small-case ASCII character.

This internal function only deal with Unicode character 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.

Parameters
CharThe character to convert.
Return values
LowerCharacterIf the Char is with range L'a' to L'z'.
UnchangedOtherwise.

Definition at line 307 of file String.c.

◆ DecimalToBcd8()

UINT8 EFIAPI DecimalToBcd8 ( IN UINT8  Value)

Converts an 8-bit value to an 8-bit BCD value.

Converts the 8-bit value specified by Value to BCD. The BCD value is returned.

If Value >= 100, then ASSERT().

Parameters
ValueThe 8-bit value to convert to BCD. Range 0..99.
Returns
The BCD value.

Definition at line 1653 of file String.c.

◆ InternalAsciiHexCharToUintn()

UINTN EFIAPI InternalAsciiHexCharToUintn ( IN CHAR8  Char)

Convert a ASCII character to numerical value.

This internal function only deal with Unicode character which maps to a valid hexadecimal ASII character, i.e. '0' to '9', 'a' to 'f' or 'A' to 'F'. For other ASCII character, the value returned does not make sense.

Parameters
CharThe character to convert.
Returns
The numerical value converted.

Definition at line 772 of file String.c.

◆ InternalAsciiIsDecimalDigitCharacter()

BOOLEAN EFIAPI InternalAsciiIsDecimalDigitCharacter ( IN CHAR8  Char)

Check if a ASCII character is a decimal character.

This internal function checks if a Unicode character is a decimal character. The valid decimal character is from '0' to '9'.

Parameters
CharThe character to check against.
Return values
TRUEIf the Char is a decmial character.
FALSEIf the Char is not a decmial character.

Definition at line 590 of file String.c.

◆ InternalAsciiIsHexaDecimalDigitCharacter()

BOOLEAN EFIAPI InternalAsciiIsHexaDecimalDigitCharacter ( IN CHAR8  Char)

Check if a ASCII character is a hexadecimal character.

This internal function checks if a ASCII character is a decimal character. The valid hexadecimal character is L'0' to L'9', L'a' to L'f', or L'A' to L'F'.

Parameters
CharThe character to check against.
Return values
TRUEIf the Char is a hexadecmial character.
FALSEIf the Char is not a hexadecmial character.

Definition at line 613 of file String.c.

◆ InternalHexCharToUintn()

UINTN EFIAPI InternalHexCharToUintn ( IN CHAR16  Char)

Convert a Unicode character to numerical value.

This internal function only deal with Unicode character which maps to a valid hexadecimal ASII character, i.e. L'0' to L'9', L'a' to L'f' or L'A' to L'F'. For other Unicode character, the value returned does not make sense.

Parameters
CharThe character to convert.
Returns
The numerical value converted.

Definition at line 333 of file String.c.

◆ InternalIsDecimalDigitCharacter()

BOOLEAN EFIAPI InternalIsDecimalDigitCharacter ( IN CHAR16  Char)

Check if a Unicode character is a decimal character.

This internal function checks if a Unicode character is a decimal character. The valid decimal character is from L'0' to L'9'.

Parameters
CharThe character to check against.
Return values
TRUEIf the Char is a decmial character.
FALSEIf the Char is not a decmial character.

Definition at line 283 of file String.c.

◆ InternalIsHexaDecimalDigitCharacter()

BOOLEAN EFIAPI InternalIsHexaDecimalDigitCharacter ( IN CHAR16  Char)

Check if a Unicode character is a hexadecimal character.

This internal function checks if a Unicode character is a decimal character. The valid hexadecimal character is L'0' to L'9', L'a' to L'f', or L'A' to L'F'.

Parameters
CharThe character to check against.
Return values
TRUEIf the Char is a hexadecmial character.
FALSEIf the Char is not a hexadecmial character.

Definition at line 360 of file String.c.

◆ StrCmp()

INTN EFIAPI StrCmp ( IN CONST CHAR16 *  FirstString,
IN CONST CHAR16 *  SecondString 
)

Compares two Null-terminated Unicode strings, and returns the difference between the first mismatched Unicode characters.

This function compares the Null-terminated Unicode string FirstString to the Null-terminated Unicode string SecondString. If FirstString is identical to SecondString, then 0 is returned. Otherwise, the value returned is the first mismatched Unicode character in SecondString subtracted from the first mismatched Unicode character in FirstString.

If FirstString is NULL, then ASSERT(). If FirstString is not aligned on a 16-bit boundary, then ASSERT(). If SecondString is NULL, then ASSERT(). If SecondString is not aligned on a 16-bit boundary, then ASSERT(). If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more than PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator, then ASSERT(). If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more than PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator, then ASSERT().

Parameters
FirstStringA pointer to a Null-terminated Unicode string.
SecondStringA pointer to a Null-terminated Unicode string.
Return values
0FirstString is identical to SecondString.
Returns
others FirstString is not identical to SecondString.

Definition at line 109 of file String.c.

◆ StrDecimalToUint64()

UINT64 EFIAPI StrDecimalToUint64 ( IN CONST CHAR16 *  String)

Convert a Null-terminated Unicode decimal string to a value of type UINT64.

This function returns a value of type UINT64 by interpreting the contents of the Unicode string specified by String as a decimal number. The format of the input Unicode string String is:

            [spaces] [decimal digits].

The valid decimal digit character is in the range [0-9]. The function will ignore the pad space, which includes spaces or tab characters, before [decimal digits]. The running zero in the beginning of [decimal digits] will be ignored. Then, the function stops at the first character that is a not a valid decimal character or a Null-terminator, whichever one comes first.

If String is NULL, then ASSERT(). If String is not aligned in a 16-bit boundary, then ASSERT(). If String has only pad spaces, then 0 is returned. If String has no pad spaces or valid decimal digits, then 0 is returned. If the number represented by String overflows according to the range defined by UINT64, then MAX_UINT64 is returned.

If PcdMaximumUnicodeStringLength is not zero, and String contains more than PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator, then ASSERT().

Parameters
StringA pointer to a Null-terminated Unicode string.
Return values
Valuetranslated from String.

Definition at line 456 of file String.c.

◆ StrDecimalToUintn()

UINTN EFIAPI StrDecimalToUintn ( IN CONST CHAR16 *  String)

Convert a Null-terminated Unicode decimal string to a value of type UINTN.

This function returns a value of type UINTN by interpreting the contents of the Unicode string specified by String as a decimal number. The format of the input Unicode string String is:

            [spaces] [decimal digits].

The valid decimal digit character is in the range [0-9]. The function will ignore the pad space, which includes spaces or tab characters, before [decimal digits]. The running zero in the beginning of [decimal digits] will be ignored. Then, the function stops at the first character that is a not a valid decimal character or a Null-terminator, whichever one comes first.

If String is NULL, then ASSERT(). If String is not aligned in a 16-bit boundary, then ASSERT(). If String has only pad spaces, then 0 is returned. If String has no pad spaces or valid decimal digits, then 0 is returned. If the number represented by String overflows according to the range defined by UINTN, then MAX_UINTN is returned.

If PcdMaximumUnicodeStringLength is not zero, and String contains more than PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator, then ASSERT().

Parameters
StringA pointer to a Null-terminated Unicode string.
Return values
Valuetranslated from String.

Definition at line 405 of file String.c.

◆ StrHexToUint64()

UINT64 EFIAPI StrHexToUint64 ( IN CONST CHAR16 *  String)

Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.

This function returns a value of type UINT64 by interpreting the contents of the Unicode string specified by String as a hexadecimal number. The format of the input Unicode string String is

            [spaces][zeros][x][hexadecimal digits].

The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F]. The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x" appears in the input string, it must be prefixed with at least one 0. The function will ignore the pad space, which includes spaces or tab characters, before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal digit. Then, the function stops at the first character that is a not a valid hexadecimal character or NULL, whichever one comes first.

If String is NULL, then ASSERT(). If String is not aligned in a 16-bit boundary, then ASSERT(). If String has only pad spaces, then zero is returned. If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then zero is returned. If the number represented by String overflows according to the range defined by UINT64, then MAX_UINT64 is returned.

If PcdMaximumUnicodeStringLength is not zero, and String contains more than PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator, then ASSERT().

Parameters
StringA pointer to a Null-terminated Unicode string.
Return values
Valuetranslated from String.

Definition at line 560 of file String.c.

◆ StrHexToUintn()

UINTN EFIAPI StrHexToUintn ( IN CONST CHAR16 *  String)

Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.

This function returns a value of type UINTN by interpreting the contents of the Unicode string specified by String as a hexadecimal number. The format of the input Unicode string String is:

            [spaces][zeros][x][hexadecimal digits].

The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F]. The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x" appears in the input string, it must be prefixed with at least one 0. The function will ignore the pad space, which includes spaces or tab characters, before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal digit. Then, the function stops at the first character that is a not a valid hexadecimal character or NULL, whichever one comes first.

If String is NULL, then ASSERT(). If String is not aligned in a 16-bit boundary, then ASSERT(). If String has only pad spaces, then zero is returned. If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then zero is returned. If the number represented by String overflows according to the range defined by UINTN, then MAX_UINTN is returned.

If PcdMaximumUnicodeStringLength is not zero, and String contains more than PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator, then ASSERT().

Parameters
StringA pointer to a Null-terminated Unicode string.
Return values
Valuetranslated from String.

Definition at line 508 of file String.c.

◆ StrLen()

UINTN EFIAPI StrLen ( IN CONST CHAR16 *  String)

Returns the length of a Null-terminated Unicode string.

This function returns the number of Unicode characters in the Null-terminated Unicode string specified by String.

If String is NULL, then ASSERT(). If String is not aligned on a 16-bit boundary, then ASSERT(). If PcdMaximumUnicodeStringLength is not zero, and String contains more than PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator, then ASSERT().

Parameters
StringA pointer to a Null-terminated Unicode string.
Returns
The length of String.

Definition at line 30 of file String.c.

◆ StrnCmp()

INTN EFIAPI StrnCmp ( IN CONST CHAR16 *  FirstString,
IN CONST CHAR16 *  SecondString,
IN UINTN  Length 
)

Compares up to a specified length the contents of two Null-terminated Unicode strings, and returns the difference between the first mismatched Unicode characters.

This function compares the Null-terminated Unicode string FirstString to the Null-terminated Unicode string SecondString. At most, Length Unicode characters will be compared. If Length is 0, then 0 is returned. If FirstString is identical to SecondString, then 0 is returned. Otherwise, the value returned is the first mismatched Unicode character in SecondString subtracted from the first mismatched Unicode character in FirstString.

If Length > 0 and FirstString is NULL, then ASSERT(). If Length > 0 and FirstString is not aligned on a 16-bit boundary, then ASSERT(). If Length > 0 and SecondString is NULL, then ASSERT(). If Length > 0 and SecondString is not aligned on a 16-bit boundary, then ASSERT(). If PcdMaximumUnicodeStringLength is not zero, and Length is greater than PcdMaximumUnicodeStringLength, then ASSERT(). If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more than PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator, then ASSERT(). If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more than PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator, then ASSERT().

Parameters
FirstStringA pointer to a Null-terminated Unicode string.
SecondStringA pointer to a Null-terminated Unicode string.
LengthThe maximum number of Unicode characters to compare.
Return values
0FirstString is identical to SecondString.
Returns
others FirstString is not identical to SecondString.

Definition at line 162 of file String.c.

◆ StrSize()

UINTN EFIAPI StrSize ( IN CONST CHAR16 *  String)

Returns the size of a Null-terminated Unicode string in bytes, including the Null terminator.

This function returns the size, in bytes, of the Null-terminated Unicode string specified by String.

If String is NULL, then ASSERT(). If String is not aligned on a 16-bit boundary, then ASSERT(). If PcdMaximumUnicodeStringLength is not zero, and String contains more than PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator, then ASSERT().

Parameters
StringA pointer to a Null-terminated Unicode string.
Returns
The size of String.

Definition at line 72 of file String.c.

◆ StrStr()

CHAR16 *EFIAPI StrStr ( IN CONST CHAR16 *  String,
IN CONST CHAR16 *  SearchString 
)

Returns the first occurrence of a Null-terminated Unicode sub-string in a Null-terminated Unicode string.

This function scans the contents of the Null-terminated Unicode string specified by String and returns the first occurrence of SearchString. If SearchString is not found in String, then NULL is returned. If the length of SearchString is zero, then String is returned.

If String is NULL, then ASSERT(). If String is not aligned on a 16-bit boundary, then ASSERT(). If SearchString is NULL, then ASSERT(). If SearchString is not aligned on a 16-bit boundary, then ASSERT().

If PcdMaximumUnicodeStringLength is not zero, and SearchString or String contains more than PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator, then ASSERT().

Parameters
StringA pointer to a Null-terminated Unicode string.
SearchStringA pointer to a Null-terminated Unicode string to search for.
Return values
NULLIf the SearchString does not appear in String.
Returns
others If there is a match.

Definition at line 224 of file String.c.

Variable Documentation

◆ EncodingTable

STATIC CHAR8 EncodingTable[]
Initial value:
= "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/"

Definition at line 1170 of file String.c.