RtlUnicodeStringToAnsiString function (wdm.h)

The RtlUnicodeStringToAnsiString routine converts a given Unicode string into an ANSI string.

Syntax

NTSYSAPI NTSTATUS RtlUnicodeStringToAnsiString(
  [in, out] PANSI_STRING     DestinationString,
  [in]      PCUNICODE_STRING SourceString,
  [in]      BOOLEAN          AllocateDestinationString
);

Parameters

[in, out] DestinationString

Pointer to an ANSI_STRING structure to hold the converted ANSI string. If AllocateDestinationString is TRUE, the routine allocates a new buffer to hold the string data, and updates the Buffer member of DestinationString to point to the new buffer. Otherwise, the routine uses the currently specified buffer to hold the string.

[in] SourceString

Pointer to the Unicode source string to be converted to ANSI.

[in] AllocateDestinationString

TRUE if this routine is to allocate the buffer space for the DestinationString. If it does, the buffer must be deallocated by calling RtlFreeAnsiString.

Return value

If the conversion succeeds, RtlUnicodeStringToAnsiString returns STATUS_SUCCESS. Otherwise, no storage was allocated, and no conversion was done.

Remarks

The translation is done in accord with the current system-locale information.

Requirements

Requirement Value
Minimum supported client Available starting with Windows 2000.
Target Platform Universal
Header wdm.h (include Wdm.h, Ntddk.h, Ntifs.h)
Library NtosKrnl.lib
DLL NtosKrnl.exe
IRQL PASSIVE_LEVEL

See also

ANSI_STRING

RtlAnsiStringToUnicodeString

RtlFreeAnsiString

UNICODE_STRING