BaseUcs2Utf8Lib.h 1.8 KB

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