Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

IdnToNameprepUnicode function

Converts an internationalized domain name (IDN) or another internationalized label to the NamePrep form specified by Network Working Group RFC 3491, but does not perform the additional conversion to Punycode. For more information and links to related draft standards, see Handling Internationalized Domain Names (IDNs).


int IdnToNameprepUnicode(
  _In_      DWORD   dwFlags,
  _In_      LPCWSTR lpUnicodeCharStr,
  _In_      int     cchUnicodeChar,
  _Out_opt_ LPWSTR  lpNameprepCharStr,
  _In_      int     cchNameprepChar


dwFlags [in]

Flags specifying conversion options. For detailed definitions, see the dwFlags parameter of IdnToAscii.

lpUnicodeCharStr [in]

Pointer to a Unicode string representing an IDN or another internationalized label.

cchUnicodeChar [in]

Count of Unicode characters in the input Unicode string indicated by lpUnicodeCharStr.

lpNameprepCharStr [out, optional]

Pointer to a buffer that receives a version of the input Unicode string converted through NamePrep processing. Alternatively, the function can retrieve NULL for this parameter, if cchNameprepChar is set to 0. In this case, the function returns the size required for this buffer.

cchNameprepChar [in]

Size, in characters, of the buffer indicated by lpNameprepCharStr. The application can set the size to 0 to retrieve NULL in lpNameprepCharStr and have the function return the required buffer size.

Return value

Returns the number of characters retrieved in lpNameprepCharStr if successful. The retrieved string is null-terminated only if the input Unicode string is null-terminated.

If the function succeeds and the value of cchNameprepChar is 0, the function returns the required size, in characters including a terminating null character if it was part of the input buffer.

The function returns 0 if it does not succeed. To get extended error information, the application can call GetLastError, which can return one of the following error codes:

  • ERROR_INSUFFICIENT_BUFFER. A supplied buffer size was not large enough, or it was incorrectly set to NULL.
  • ERROR_INVALID_FLAGS. The values supplied for flags were not valid.
  • ERROR_INVALID_NAME. An invalid name was supplied to the function. Note that this error code catches all syntax errors.
  • ERROR_INVALID_PARAMETER. Any of the parameter values was invalid.
  • ERROR_NO_UNICODE_TRANSLATION. Invalid Unicode was found in a string.


See Remarks for IdnToAscii.


NLS: Internationalized Domain Name (IDN) Conversion Sample demonstrates the use of this function.


Minimum supported client

Windows Vista [desktop apps | UWP apps]

Minimum supported server

Windows Server 2008 [desktop apps | UWP apps]


Microsoft Internationalized Domain Name (IDN) Mitigation APIs onWindows XP with SP2 and later, orWindows Server 2003 with SP1


Winnls.h (include Windows.h)





See also

National Language Support
National Language Support Functions
Handling Internationalized Domain Names (IDNs)



© 2018 Microsoft