dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnet/support locale.c,1.3,1.4


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnet/support locale.c,1.3,1.4
Date: Wed, 13 Nov 2002 23:07:30 -0500

Update of /cvsroot/dotgnu-pnet/pnet/support
In directory subversions:/tmp/cvs-serv4785/support

Modified Files:
        locale.c 
Log Message:


Integrate the culture-determination code.


Index: locale.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/support/locale.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** locale.c    16 Jun 2002 11:36:01 -0000      1.3
--- locale.c    14 Nov 2002 04:07:27 -0000      1.4
***************
*** 232,235 ****
--- 232,288 ----
  }
  
+ unsigned ILGetCultureID(void)
+ {
+       /* We prefer to return culture information by name */
+       return 0;
+ }
+ 
+ /*
+  * Locale-safe letter manipulation macros.
+  */
+ #define       IsAlpha(ch)     (((ch) >= 'A' && (ch) <= 'Z') || \
+                                        ((ch) >= 'a' && (ch) <= 'z'))
+ #define       ToLower(ch)     (((ch) >= 'A' && (ch) <= 'Z') ? (ch) - 'A' + 
'a' : (ch))
+ #define       ToUpper(ch)     (((ch) >= 'a' && (ch) <= 'z') ? (ch) - 'a' + 
'A' : (ch))
+ 
+ char *ILGetCultureName(void)
+ {
+       char *env;
+       char name[8];
+ 
+       /* Get the culture information from the LANG environment variable */
+       env = getenv("LANG");
+       if(!env || *env == '\0')
+       {
+               return 0;
+       }
+ 
+       /* Convert the LANG value into an ECMA culture identifier */
+       if(!IsAlpha(env[0]) || !IsAlpha(env[1]))
+       {
+               return 0;
+       }
+       name[0] = ToLower(env[0]);
+       name[1] = ToLower(env[1]);
+       if(env[2] == '\0')
+       {
+               name[2] = '\0';
+               return ILDupString(name);
+       }
+       if(env[2] != '-' && env[2] != '_')
+       {
+               return 0;
+       }
+       if(!IsAlpha(env[3]) || !IsAlpha(env[4]))
+       {
+               return 0;
+       }
+       name[3] = '-';
+       name[4] = ToUpper(env[3]);
+       name[5] = ToUpper(env[4]);
+       name[6] = '\0';
+       return ILDupString(name);
+ }
+ 
  #ifdef        __cplusplus
  };





reply via email to

[Prev in Thread] Current Thread [Next in Thread]