TianoCore EDK2 master
Loading...
Searching...
No Matches
BaseUcs2Utf8Lib.c File Reference

Go to the source code of this file.

Functions

UINT8 GetUTF8SizeForUCS2 (IN CHAR8 *Utf8Buffer)
 
EFI_STATUS GetUCS2CharByFormat (IN CHAR8 *Utf8Buffer, OUT CHAR16 *Ucs2Char)
 
UINT8 UCS2CharToUTF8 (IN CHAR16 Ucs2Char, OUT CHAR8 *Utf8Buffer)
 
EFI_STATUS UTF8ToUCS2Char (IN CHAR8 *Utf8Buffer, OUT CHAR16 *Ucs2Char)
 
EFI_STATUS UCS2StrToUTF8 (IN CHAR16 *Ucs2Str, OUT CHAR8 **Utf8StrAddr)
 
EFI_STATUS UTF8StrToUCS2 (IN CHAR8 *Utf8Str, OUT CHAR16 **Ucs2StrAddr)
 

Detailed Description

UCS2 to UTF8 manipulation library.

Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.
(C) Copyright 2020 Hewlett Packard Enterprise Development LP

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file BaseUcs2Utf8Lib.c.

Function Documentation

◆ GetUCS2CharByFormat()

EFI_STATUS GetUCS2CharByFormat ( IN CHAR8 *  Utf8Buffer,
OUT CHAR16 *  Ucs2Char 
)

Since each UCS2 character can be represented by the format: \uXXXX, this function is used to retrieve the UCS2 character from a Unicode format. Call MUST make sure there are at least 6 Bytes in the input UTF8 buffer.

Parameters
[in]Utf8BufferThe buffer for UTF8 encoded data.
[out]Ucs2CharThe converted UCS2 character.
Return values
EFI_INVALID_PARAMETERNon-Ascii characters found in the hexadecimal digits string, and can't be converted to a UCS2 character.
EFI_SUCCESSThe UCS2 character has been retrieved.

two Hexadecimal digits Ascii string, like "3F"

Definition at line 73 of file BaseUcs2Utf8Lib.c.

◆ GetUTF8SizeForUCS2()

UINT8 GetUTF8SizeForUCS2 ( IN CHAR8 *  Utf8Buffer)

Since each UCS2 character can be represented by 1-3 UTF8 encoded characters, this function is used to retrieve the UTF8 encoding size for a UCS2 character.

Parameters
[in]Utf8BufferThe buffer for UTF8 encoded data.
Return values
Returnthe size of UTF8 encoding string or 0 if it is not for UCS2 format.

Definition at line 28 of file BaseUcs2Utf8Lib.c.

◆ UCS2CharToUTF8()

UINT8 UCS2CharToUTF8 ( IN CHAR16  Ucs2Char,
OUT CHAR8 *  Utf8Buffer 
)

Convert a UCS2 character to UTF8 encoding string.

Parameters
[in]Ucs2CharThe provided UCS2 character.
[out]Utf8BufferThe converted UTF8 encoded data.
Return values
Returnthe size of UTF8 encoding data for this UCS2 character.

Ucs2Number >= 0x0800 && Ucs2Number <= 0xFFFF

Definition at line 122 of file BaseUcs2Utf8Lib.c.

◆ UCS2StrToUTF8()

EFI_STATUS UCS2StrToUTF8 ( IN CHAR16 *  Ucs2Str,
OUT CHAR8 **  Utf8StrAddr 
)

Convert a UCS2 string to a UTF8 encoded string.

Parameters
[in]Ucs2StrThe provided UCS2 string.
[out]Utf8StrAddrThe converted UTF8 string address. Caller is responsible for Free this string.
Return values
EFI_INVALID_PARAMETEROne or more parameters are invalid.
EFI_OUT_OF_RESOURCESSystem runs out of resources.
EFI_SUCCESSThe UTF8 encoded string has been converted.

Definition at line 266 of file BaseUcs2Utf8Lib.c.

◆ UTF8StrToUCS2()

EFI_STATUS UTF8StrToUCS2 ( IN CHAR8 *  Utf8Str,
OUT CHAR16 **  Ucs2StrAddr 
)

Convert a UTF8 encoded string to a UCS2 string.

Parameters
[in]Utf8StrThe provided UTF8 encoded string.
[out]Ucs2StrAddrThe converted UCS2 string address. Caller is responsible for Free this string.
Return values
EFI_INVALID_PARAMETERThe UTF8 encoded string is not valid to convert to UCS2 string. One or more parameters are invalid.
EFI_OUT_OF_RESOURCESSystem runs out of resources.
EFI_SUCCESSThe UCS2 string has been converted.

Definition at line 327 of file BaseUcs2Utf8Lib.c.

◆ UTF8ToUCS2Char()

EFI_STATUS UTF8ToUCS2Char ( IN CHAR8 *  Utf8Buffer,
OUT CHAR16 *  Ucs2Char 
)

Convert a UTF8 encoded data to a UCS2 character.

Parameters
[in]Utf8BufferThe provided UTF8 encoded data.
[out]Ucs2CharThe converted UCS2 character.
Return values
EFI_INVALID_PARAMETERThe UTF8 encoded string is not valid or not for UCS2 character.
EFI_SUCCESSThe converted UCS2 character.

Definition at line 170 of file BaseUcs2Utf8Lib.c.