搜尋此網誌

2012年8月2日 星期四

Convert the ASCII string <=> a UNICODE string


/************************************************************/
CHAR16 *
AsciiStrToUnicodeStr (
  IN  CHAR8   *Source,
  OUT CHAR16  *Destination
  )
/*++
Routine Description:
  Convert the ASCII string into a UNICODE string.
Arguments:
  Source      - The ASCII string.
  Destination - The storage to return the UNICODE string.
Returns:
  Pointer to the UNICODE string.
--*/
{
  ASSERT (Destination != NULL);
  ASSERT (Source != NULL);

  while (*Source != '\0') {
    *(Destination++) = (CHAR16) *(Source++);
  }

  *Destination = '\0';

  return Destination;
}
/************************************************************/

/************************************************************/
CHAR8 *
UnicodeStrToAsciiStr (
  IN  CHAR16   *Source,
  OUT  CHAR8  *Destination
  )
/*++
Routine Description:
  Convert the UNICODE string into a ASCII  string.
Arguments:
  Source      - The storage to return the UNICODE string.
  Destination - The ASCII string.
Returns:
  Pointer to the UNICODE string.
--*/

{
  ASSERT (Destination != NULL);
  ASSERT (Source != NULL);

  while (*Source != '\0') {
    *(Destination++) = (CHAR8) *(Source++);
  }

  *Destination = '\0';

  return Destination;
}

/************************************************************/

沒有留言:

張貼留言