L_Setlocale

#include "l_bitmap.h"

L_LTKRN_API L_CHAR * L_Setlocale(category, locale)

L_INT category;

/* category affected by the locale */

const L_CHAR * locale;

/* locale name */

Sets the locale for the library.

Parameter

Description

category

Category affected by the locale.

locale

Locale name.  Pass NULL to return the current locale.

Returns

!NULL

A pointer to the string representing the specified locale and category

NULL

Indicates that the category or locale parameter value was invalid

Comments

This function is used under rare circumstances. It is necessary only when running non-UNICODE applications that must deal with text (for example, filename strings) that is not part of the ASCII character set (for example, Japanese characters). Non-ASCII text (i.e. a Japanese or Arabic character) can be stored non-ambiguously in UNICODE. However, for non-UNICODE applications, the multi-byte representation of such characters depends on the code page. In this case, you must set the code page appropriately. For example, a non-UNICODE application can display Japanese characters only if the code page is set to a Japanese code page (like Japanese_Japan.932).

Pass NULL for the parameter locale to get the current locale, leaving the current locale unchanged.

Internally, this function calls the Microsoft C runtime function, setlocale. For details, see the MSDN documentation.

Required DLLs and Libraries

LTKRN

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

Platforms

Win32, x64.

See Also

Functions:

L_LoadFile, L_FileInfo

Topics:

Using the UNICODE version of LEADTOOLS in a non-UNICODE Application

Example

This example shows how to set the locale of the LEADTOOLS library. Also, see the tutotorial "Using the UNICODE version of LEADTOOLS in a non-UNICODE Application".

#include <locale.h>
L_CHAR* DisplayCurrentLocale()
{
   // Display the current locale
   L_CHAR *pszMsg = L_Setlocale(LC_ALL, NULL);
   if (pszMsg != NULL)
      MessageBoxA(NULL, pszMsg, "Current Locale", MB_OK);
   return pszMsg;
}

L_INT SetlocaleExample() 
{   
   L_CHAR *pszOriginalLocale = DisplayCurrentLocale();

   // Set the locale for English/United states
   L_Setlocale(LC_ALL, "English");
   DisplayCurrentLocale();


   // Set the locale for Japanese
   L_Setlocale(LC_ALL, "Japanese");
   DisplayCurrentLocale();

   // Set the locale for arabic
   L_Setlocale(LC_ALL, "Arabic");
   DisplayCurrentLocale();

   // Set to the original locale
   L_Setlocale(LC_ALL, pszOriginalLocale);
   DisplayCurrentLocale();

   return SUCCESS;
}