home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / bc45 / classsrc.pak / LOCALECO.CPP < prev    next >
C/C++ Source or Header  |  1997-07-23  |  2KB  |  67 lines

  1. //----------------------------------------------------------------------------
  2. // (C) Copyright 1994 by Borland International, All Rights Reserved
  3. //
  4. // TLocaleString default NLS compare function - used only if non-OLE
  5. //----------------------------------------------------------------------------
  6. #if !defined(_Windows)
  7. # define _Windows      // pretend we are in windows to get the headers we need
  8. #endif
  9. #include <osl/locale.h>
  10.  
  11. #if defined(BI_PLAT_WIN32)
  12.  
  13. TLangId
  14. TLocaleString::GetSystemLangId()
  15. {
  16.   return ::GetSystemDefaultLangID();
  17. }
  18.  
  19. TLangId
  20. TLocaleString::GetUserLangId()
  21. {
  22.   return ::GetUserDefaultLangID();
  23. }
  24.  
  25. int
  26. TLocaleString::CompareLang(const char far* s1, const char far* s2, TLangId lang)
  27. {
  28.   typedef int WINAPI (*TCompareStringA)(LCID, DWORD, LPCSTR, int, LPCSTR, int);
  29.   
  30.   static int WINAPI (*compareStringA)(LCID, DWORD, LPCSTR, int, LPCSTR, int) =
  31.     (TCompareStringA)::GetProcAddress(::GetModuleHandle("kernel32"), "CompareStringA");
  32.  
  33.   // Use CompareStringA if it is available
  34.   //
  35.   if (compareStringA)
  36.     return compareStringA(lang, NORM_IGNORECASE | NORM_IGNORENONSPACE,
  37.                           s1,-1, s2,-1) - 2;
  38.  
  39.   // Otherwise just use RTL function
  40.   //
  41.   return _fstricmp(s1, s2);  // only permissible if not an OLE application
  42. }
  43.  
  44. #else
  45.  
  46. #include <string.h>
  47.  
  48. TLangId
  49. TLocaleString::GetSystemLangId()
  50. {
  51.   return 0x409;  // US English if no OLE or Win32 support
  52. }
  53.  
  54. TLangId
  55. TLocaleString::GetUserLangId()
  56. {
  57.   return 0x409;  // US English if no OLE or Win32 support
  58. }
  59.  
  60. int
  61. TLocaleString::CompareLang(const char far* s1, const char far* s2, TLangId)
  62. {
  63.   return _fstricmp(s1, s2);  // only permissible if not an OLE application
  64. }
  65.  
  66. #endif
  67.