LCIDToLocaleName function

Converts a locale identifier to a locale name.

Note  For custom locales, including those created by Microsoft, your applications should prefer locale names over locale identifiers.


int LCIDToLocaleName(
  _In_      LCID   Locale,
  _Out_opt_ LPWSTR lpName,
  _In_      int    cchName,
  _In_      DWORD  dwFlags


Locale [in]

Locale identifier to translate. You can use the MAKELCID macro to create a locale identifier or use one of the following predefined values.

Windows Vista: The following custom locale identifiers are also supported.

lpName [out, optional]

Pointer to a buffer in which this function retrieves the locale name, or one of the following predefined values.

cchName [in]

Size, in characters, of the locale name buffer. The maximum possible length of a locale name, including a terminating null character, is LOCALE_NAME_MAX_LENGTH. This is the recommended size to supply for this parameter.

Alternatively, the application can set this parameter to 0. In this case, the function returns the required size for the locale name buffer.

dwFlags [in]

Before Windows 7: Reserved; should always be 0.

Starting with Windows 7: Can be set to LOCALE_ALLOW_NEUTRAL_NAMES to allow the return of a neutral name.

Return value

Returns the count of characters, including the terminating null character, in the locale name if successful. If the function succeeds and the value of cchName is 0, the return value is the required size, in characters (including nulls), for the locale name 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_PARAMETER. Any of the parameter values was invalid.


#include "stdafx.h"
#include "windows.h"
#include "stdio.h"

int _cdecl main(
    int argc,
    char *argv[])
    LCID  lcid;

    // Get the name for locale 0x10407 (German (German), with phonebook sort)
    if (LCIDToLocaleName(0x10407, strNameBuffer, LOCALE_NAME_MAX_LENGTH, 0) == 0)
        // There was an error
        error = GetLastError();
        // Success, display the locale name we found
        wprintf(L"Locale Name for 0x10407 is %s\n", strNameBuffer);

    // Get the LCID for the locale
    lcid = LocaleNameToLCID(strNameBuffer, 0);
    if (lcid == 0)
        // There was an error
        error = GetLastError();
        // Success, print the round trip LCID
        wprintf(L"LCID for %s is 0x%x\n", strNameBuffer, lcid);

/* This code example produces the following output:

Locale Name for 0x10407 is de-DE_phoneb
LCID for de-DE_phoneb is 0x10407



Minimum supported client

Windows Vista [desktop apps | Windows Store apps]

Minimum supported server

Windows Server 2008 [desktop apps | Windows Store apps]

Minimum supported phone

Windows Phone 8


Winnls.h (include Windows.h)





See also

National Language Support
National Language Support Functions