Previous Next

RtlUnicodeStringToAnsiString

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

NTSTATUS 
  RtlUnicodeStringToAnsiString(
    IN OUT PANSI_STRING  DestinationString,
    IN PUNICODE_STRING  SourceString,
    IN BOOLEAN  AllocateDestinationString
    );

Parameters

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.
SourceString
Pointer to the Unicode source string to be converted to ANSI.
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.

Headers

Declared in wdm.h and ntddk.h. Include wdm.h or ntddk.h.

Comments

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

Callers of RtUnicodeStringToAnsiString must be running at IRQL = PASSIVE_LEVEL.

See Also

ANSI_STRING, UNICODE_STRING, RtlAnsiStringToUnicodeString, RtlFreeAnsiString