home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / xp / xplocale.c < prev   
Encoding:
C/C++ Source or Header  |  1998-04-08  |  2.7 KB  |  111 lines

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. /* *
  20.  * 
  21.  *
  22.  * xplocale.c
  23.  * ----------
  24.  */
  25.  
  26. /* xp headers */ 
  27. #include "xplocale.h"
  28. #include "ntypes.h"
  29. #include "xp_str.h"
  30.  
  31. #include "prtypes.h"
  32. #include "xpgetstr.h"
  33. #include "csid.h"    /* Need to access CS_DEFAULT */
  34. #include "libi18n.h"    /* Need to access     
  35.                 INTL_CharSetNameToID()
  36.                 INTL_ResourceCharSet()    
  37.                We should consider rename INTL_ResourceCharSet()
  38.                    into XP_CharSetOfGetString() and move to here
  39.             */
  40. #ifndef FALSE
  41. #define FALSE (0)
  42. #endif
  43. #ifndef TRUE
  44. #define TRUE (1)
  45. #endif
  46.  
  47. /* fun: XP_StrColl 
  48. * ---------------
  49. * Takes two strings to compare, compares them, 
  50. * and returns a number less than 0 if the second
  51. * string is greater, 0 if they are the same, 
  52. * and greater than 0 if the first string is 
  53. * greater, according to the sorting rules 
  54. * appropriate for the current locale.
  55. */
  56.  
  57. int XP_StrColl(const char* s1, const  char* s2) 
  58. {
  59.     return(FE_StrColl(s1, s2));    
  60. }    
  61.  
  62.  
  63. /* XP_StrfTime */
  64. /* Returns 0 on error, size of return string otherwise */
  65.  
  66.  
  67. size_t XP_StrfTime(MWContext* context, char *result, size_t maxsize, int format,
  68.     const struct tm *timeptr)
  69.  
  70. {
  71.  
  72. /* Maybe eventually do some locale setting here */
  73. return(FE_StrfTime(context, result, maxsize, format, timeptr));
  74.  
  75.  
  76.  
  77. const char* INTL_ctime(MWContext* context, time_t *date)
  78. {
  79.   static char result[40];    
  80. #ifdef XP_WIN
  81.   if (*date < 0 || *date > 0x7FFFFFFF)
  82.     *date = 0x7FFFFFFF;
  83. #endif
  84.   if(date != NULL)
  85.   {
  86.       XP_StrfTime(context, result, sizeof(result), XP_LONG_DATE_TIME_FORMAT, localtime(date));
  87.   } else {
  88.         result[0] = '\0';
  89.   }
  90.   return result;
  91. }
  92.  
  93. static int16 res_csid = CS_DEFAULT;
  94. char *XP_GetStringForHTML(int i, int16 wincsid, char* english)
  95. {
  96.     /* Need to do some initialization */
  97.     if(res_csid == CS_DEFAULT)
  98.         res_csid = INTL_CharSetNameToID(INTL_ResourceCharSet());
  99.  
  100.     if(INTL_DocToWinCharSetID(wincsid) == res_csid)
  101.         return XP_GetString(i);
  102.     else
  103.         return english;
  104.         
  105. }
  106.  
  107.  
  108.  
  109.  
  110.