]> git.proxmox.com Git - mirror_edk2.git/blob - RedfishPkg/Include/Library/BaseUcs2Utf8Lib.h
RedfishPkg/Ucs2Utf8lib: UCS2 to UFT8 manipulation library
[mirror_edk2.git] / RedfishPkg / Include / Library / BaseUcs2Utf8Lib.h
1 /** @file
2 UCS2 to UTF8 manipulation library header file.
3
4 Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
5 (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
6
7 SPDX-License-Identifier: BSD-2-Clause-Patent
8
9 **/
10
11 #ifndef BASE_UCS2UTF8_LIB_H_
12 #define BASE_UCS2UTF8_LIB_H_
13
14 ///
15 /// L"\u0000"
16 ///
17 #define UNICODE_FORMAT_LEN 6
18 #define UNICODE_FORMAT_CHAR_LEN 2
19 #define UNICODE_FORMAT_CHAR_SIZE 3
20
21 #define UTF8_BUFFER_FOR_UCS2_MAX_SIZE 3
22
23 /**
24 Convert a UCS2 string to a UTF8 encoded string.
25
26 @param[in] Ucs2Str The provided UCS2 string.
27 @param[out] Utf8StrAddr The converted UTF8 string address. Caller
28 is responsible for Free this string.
29
30 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
31 @retval EFI_OUT_OF_RESOURCES System runs out of resources.
32 @retval EFI_SUCCESS The UTF8 encoded string has been converted.
33
34 **/
35 EFI_STATUS
36 UCS2StrToUTF8 (
37 IN CHAR16 *Ucs2Str,
38 OUT CHAR8 **Utf8StrAddr
39 );
40
41 /**
42 Convert a UTF8 encoded string to a UCS2 string.
43
44 @param[in] Utf8Str The provided UTF8 encoded string.
45 @param[out] Ucs2StrAddr The converted UCS2 string address. Caller
46 is responsible for Free this string.
47
48 @retval EFI_INVALID_PARAMETER The UTF8 encoded string is not valid to
49 convert to UCS2 string.
50 One or more parameters are invalid.
51 @retval EFI_OUT_OF_RESOURCES System runs out of resources.
52 @retval EFI_SUCCESS The UCS2 string has been converted.
53
54 **/
55 EFI_STATUS
56 UTF8StrToUCS2 (
57 IN CHAR8 *Utf8Str,
58 OUT CHAR16 **Ucs2StrAddr
59 );
60
61 #endif