RtlMultiByteToUnicodeSize - NtDoc

Native API online documentation, based on the System Informer (formerly Process Hacker) phnt headers
#ifndef _NTRTL_H

/**
 * The RtlMultiByteToUnicodeSize routine determines the number of bytes that are required to store the Unicode translation for the specified source string.
 * The translation is assumed to use the current system ANSI code page (ACP). The source string is not necessarily from a multibyte character set.
 *
 * \param BytesInUnicodeString Pointer to a caller-allocated variable that receives the number of bytes that are required to store the translated string.
 * \param MultiByteString Pointer to the source string for which the Unicode length is to be calculated.
 * \param BytesInMultiByteString Length, in bytes, of the source string.
 * \return NTSTATUS Successful or errant status.
 * \sa https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/nf-ntifs-rtlmultibytetounicodesize
 */
NTSYSAPI
NTSTATUS
NTAPI
RtlMultiByteToUnicodeSize(
    _Out_ PULONG BytesInUnicodeString,
    _In_reads_bytes_(BytesInMultiByteString) PCSTR MultiByteString,
    _In_ ULONG BytesInMultiByteString
    );

#endif

View code on GitHub
// ntifs.h

NTSYSAPI NTSTATUS RtlMultiByteToUnicodeSize(
  [out] PULONG     BytesInUnicodeString,
  [in]  const CHAR *MultiByteString,
  [in]  ULONG      BytesInMultiByteString
);

View the official Windows Driver Kit DDI reference

NtDoc

This function is documented in Windows Driver Kit.

Windows Driver Kit DDI reference (nf-ntifs-rtlmultibytetounicodesize)

RtlMultiByteToUnicodeSize function

Description

The RtlMultiByteToUnicodeSize routine determines the number of bytes that are required to store the Unicode translation for the specified source string. The translation is assumed to use the current system ANSI code page (ACP). The source string is not necessarily from a multibyte character set.

Parameters

BytesInUnicodeString [out]

Pointer to a caller-allocated variable that receives the number of bytes that are required to store the translated string.

MultiByteString [in]

Pointer to the source string for which the Unicode length is to be calculated.

BytesInMultiByteString [in]

Length, in bytes, of the source string.

Return value

RtlMultiByteToUnicodeSize returns STATUS_SUCCESS.

Remarks

RtlMultiByteToUnicodeSize can be called to determine how much memory to allocate, or possibly, the value to specify for MaxBytesInUnicodeString, before translating a multibyte string into Unicode with RtlMultiByteToUnicodeN. The returned value does not include space for a NULL terminator for the Unicode string.

Like RtlMultiByteToUnicodeN, RtlMultiByteToUnicodeSize supports only precomposed Unicode characters that are mapped to the current system ANSI code page installed at system boot.

For information about other string-handling routines, see Run-Time Library (RTL) Routines.

See also

RtlMultiByteToUnicodeN

RtlUnicodeToMultiByteSize