/* 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. */
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. */
EFI_STATUS GetUCS2CharByFormat(IN CHAR8 *Utf8Buffer, OUT CHAR16 *Ucs2Char)
{
  UINT8  Num1;
  UINT8  Num2;
  UINT8  Index;
  CHAR8  Ucs2CharFormat[UNICODE_FORMAT_CHAR_SIZE];
  for (Index = 0; Index < 4; Index++) {
    if ((*(Utf8Buffer + 2 + Index) & 0x80) != 0x00) {
      return EFI_INVALID_PARAMETER;
    }
  }
  ZeroMem (Ucs2CharFormat, UNICODE_FORMAT_CHAR_SIZE);
  CopyMem (Ucs2CharFormat, Utf8Buffer + 2, UNICODE_FORMAT_CHAR_LEN);
  Num1 = (UINT8)AsciiStrHexToUintn (Ucs2CharFormat);
  CopyMem (Ucs2CharFormat, Utf8Buffer + 4, UNICODE_FORMAT_CHAR_LEN);
  Num2 = (UINT8)AsciiStrHexToUintn (Ucs2CharFormat);
  *((CHAR8 *)Ucs2Char)       = Num2;
  *(((CHAR8 *)Ucs2Char) + 1) = Num1;
  return EFI_SUCCESS;
}