From 7e8244bce70f66f824283473d1c5d1cb3f2aecd3 Mon Sep 17 00:00:00 2001 From: Pablo Saratxaga Date: Sat, 10 Oct 1998 15:46:43 +0000 Subject: [PATCH] Added function to build the Windows numeric language ID from language, code, charset and dialect strings, like used by Unix LANG variable. --- misc/main.c | 351 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 351 insertions(+) diff --git a/misc/main.c b/misc/main.c index 830f9845d74..7f16805ed09 100644 --- a/misc/main.c +++ b/misc/main.c @@ -32,6 +32,7 @@ #include "debugdefs.h" #include "xmalloc.h" #include "version.h" +#include "winnls.h" /* when adding new languages look at ole/ole2nls.c * for proper iso name and Windows code (add 0x0400 @@ -327,6 +328,356 @@ static BOOL32 MAIN_ParseDebugOptions(char *options) } /*********************************************************************** + * MAIN_GetLanguageID + * + * INPUT: + * Lang: a string whose two first chars are the iso name of a language. + * Country: a string whose two first chars are the iso name of country + * Charset: a string defining the chossen charset encoding + * Dialect: a string defining a variation of the locale + * + * all those values are from the standardized format of locale + * name in unix which is: Lang[_Country][.Charset][@Dialect] + * + * RETURNS: + * the numeric code of the language used by Windows (or 0x00) + */ +int MAIN_GetLanguageID(char *Lang, char *Country, char *Charset, char *Dialect) +{ + char lang[3]="??", country[3]={0,0,0}; + char *charset=NULL, *dialect=NULL; + int i,j,ret=0; + + if (Lang==NULL) return 0x00; + if (Lang[0]) lang[0]=tolower(Lang[0]); + if (Lang[1]) lang[1]=tolower(Lang[1]); + + if (Country!=NULL) { + if (Country[0]) country[0]=toupper(Country[0]); + if (Country[1]) country[1]=toupper(Country[1]); + } + + if (Charset!=NULL) { + j=strlen(Charset); + charset=(char*)malloc(j+1); + for (i=0;i 0x56 +/*x57*/ /*LANG_ENTRY_BEGIN( "??", KONKANI ) + LANG_ENTRY_END( KONKANI ) */ +// 0x58 -> ... + LANG_ENTRY_BEGIN( "eo", ESPERANTO ) /* not official */ + LANG_ENTRY_END( ESPERANTO ) + + ret = LANG_NEUTRAL; + +end_MAIN_GetLanguageID: + if (Charset) free(Charset); + if (Dialect) free(Dialect); + + return ret; +} + +/*********************************************************************** * MAIN_ParseLanguageOption * * Parse -language option. -- 2.11.4.GIT