Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

164 lines
3.9 KiB

  1. // ========================================================================
  2. //
  3. // Module: langtocpid.h
  4. //
  5. // Copyright Microsoft Corporation 1997, All Rights Reserved.
  6. //
  7. // Description: This file is used provide the support for HTTP_DAV
  8. // to make a best guess code page based on the Accept-
  9. // Language header. The code page is used to decode
  10. // non-UTF8 chanracters in URLs coming from Office/Rosebud
  11. // This file contains the static mapping of header values
  12. // to code pages as well as a cache to provide fast
  13. // retrieval of code pages.
  14. //
  15. // ========================================================================
  16. #ifndef _LANGTOCPID_H_
  17. #define _LANGTOCPID_H_
  18. #include <ex\gencache.h>
  19. #include <singlton.h>
  20. struct ACCEPTLANGTOCPID_ENTRY { LPCSTR pszLang; UINT cpid; };
  21. // A static mapping of Accept-Language header values to the
  22. // corresponding CPIDs. This mapping comes from the DAV
  23. // implementation doc
  24. // http://exchange/doc/specs/Platinum/Future%20Protocols/ms-implementation/dav-codepage-support.doc
  25. //
  26. DEC_CONST ACCEPTLANGTOCPID_ENTRY gc_rgAcceptLangToCPIDTable[] =
  27. {
  28. {"ar", 1256},
  29. {"ar-sa", 1256},
  30. {"ar-iq", 1256},
  31. {"ar-eg", 1256},
  32. {"ar-ly", 1256},
  33. {"ar-dz", 1256},
  34. {"ar-ma", 1256},
  35. {"ar-tn", 1256},
  36. {"ar-om", 1256},
  37. {"ar-ye", 1256},
  38. {"ar-sy", 1256},
  39. {"ar-jo", 1256},
  40. {"ar-lb", 1256},
  41. {"ar-kw", 1256},
  42. {"ar-ae", 1256},
  43. {"ar-bh", 1256},
  44. {"ar-qa", 1256},
  45. {"zh", 950},
  46. {"zh-tw", 950},
  47. {"zh-cn", 936},
  48. {"zh-hk", 950},
  49. {"zh-sg", 936},
  50. {"ja", 932},
  51. {"en-us", 1252},
  52. {"en-gb", 1252},
  53. {"en-au", 1252},
  54. {"en-ca", 1252},
  55. {"en-nz", 1252},
  56. {"en-ie", 1252},
  57. {"en-za", 1252},
  58. {"en-jm", 1252},
  59. {"en-bz", 1252},
  60. {"en-tt", 1252},
  61. {"fr", 1252},
  62. {"fr-be", 1252},
  63. {"fr-ca", 1252},
  64. {"fr-ch", 1252},
  65. {"fr-lu", 1252},
  66. {"de", 1252},
  67. {"de-ch", 1252},
  68. {"de-at", 1252},
  69. {"de-lu", 1252},
  70. {"de-li", 1252},
  71. {"el", 1253},
  72. {"he", 1255},
  73. {"it", 1252},
  74. {"it-ch", 1252},
  75. {"lt", 1257},
  76. {"ko", 949},
  77. {"es", 1252},
  78. {"es-mx", 1252},
  79. {"es-gt", 1252},
  80. {"es-cr", 1252},
  81. {"es-pa", 1252},
  82. {"es-do", 1252},
  83. {"es-ve", 1252},
  84. {"es-co", 1252},
  85. {"es-pe", 1252},
  86. {"es-ar", 1252},
  87. {"es-ec", 1252},
  88. {"es-cl", 1252},
  89. {"es-uy", 1252},
  90. {"es-py", 1252},
  91. {"es-bo", 1252},
  92. {"es-sv", 1252},
  93. {"es-hn", 1252},
  94. {"es-ni", 1252},
  95. {"es-pr", 1252},
  96. {"ru", 1251},
  97. {"th", 874},
  98. {"tr", 1254},
  99. {"vi", 1258}
  100. };
  101. // The size of the table
  102. //
  103. const DWORD gc_cAcceptLangToCPIDTable = CElems(gc_rgAcceptLangToCPIDTable);
  104. // ========================================================================
  105. //
  106. // Singleton class CLangToCpidCache
  107. //
  108. // A cache to provide fast retrieval of code pages based on values in the
  109. // Accept-Language header.
  110. //
  111. //
  112. class CLangToCpidCache : private Singleton<CLangToCpidCache>
  113. {
  114. private:
  115. //
  116. // Friend declarations required by Singleton template
  117. //
  118. friend class Singleton<CLangToCpidCache>;
  119. // The cache mapping accept language strings to code pages.
  120. //
  121. CCache<CRCSzi, UINT> m_cacheAcceptLangToCPID;
  122. // CONSTRUCTORS
  123. //
  124. // Declared private to ensure that arbitrary instances
  125. // of this class cannot be created. The Singleton
  126. // template (declared as a friend above) controls
  127. // the sole instance of this class.
  128. //
  129. CLangToCpidCache() {};
  130. // NOT IMPLEMENTED
  131. //
  132. CLangToCpidCache (const CLangToCpidCache&);
  133. CLangToCpidCache& operator= (const CLangToCpidCache&);
  134. public:
  135. // STATICS
  136. //
  137. //
  138. // Instance creating/destroying routines provided
  139. // by the Singleton template.
  140. //
  141. using Singleton<CLangToCpidCache>::DestroyInstance;
  142. // Initialization. Wraps CreateInstance().
  143. // This function hashes all the supported language strings
  144. // to give us quick lookup by language string.
  145. //
  146. static BOOL FCreateInstance();
  147. // Find the CPID from language string
  148. //
  149. static BOOL FFindCpid(IN LPCSTR pszLang, OUT UINT * puiCpid);
  150. };
  151. #endif // _LANGTOCPID_H_