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.

159 lines
3.3 KiB

  1. /*++
  2. Copyright (c) 1996-1997 Microsoft Corporation
  3. Module Name:
  4. dbcsutil.c
  5. Abstract:
  6. Double byte font/character handling functions (for CJK)
  7. Environment:
  8. Windows NT printer drivers
  9. Revision History:
  10. 10/8/97 -eigos-
  11. Removed BIsDBCSLeadByteXXX functions and Added TranslateCharSetInfo and
  12. GetACP.
  13. 01/20/97 -eigos-
  14. Created it.
  15. --*/
  16. #include "lib.h"
  17. //
  18. //
  19. // This is a hack implementation (although very close to the real one)
  20. // so that all the places in the code that need to know what the default
  21. // charset and/or codepage is don't have duplicate code all over the place.
  22. // This allows us to have a single binary for Japan/Korea/Chinese.
  23. //
  24. // This code copied from \\rastaman\ntwin!src\ntgdi\gre\mapfile.c
  25. //
  26. // We should not call GreTranslateCharsetInfo and GreXXXX.
  27. // So, MyTranslateCharsetInfo is here.
  28. //
  29. //
  30. #define NCHARSETS 14
  31. //
  32. // Globals
  33. //
  34. struct _CHARSETINFO {
  35. UINT CharSet;
  36. UINT CodePage;
  37. } CharSetInfo[NCHARSETS] = {
  38. { ANSI_CHARSET, 1252},
  39. { SHIFTJIS_CHARSET, 932},
  40. { HANGEUL_CHARSET, 949},
  41. { JOHAB_CHARSET, 1361},
  42. { GB2312_CHARSET, 936},
  43. { CHINESEBIG5_CHARSET, 950},
  44. { HEBREW_CHARSET, 1255},
  45. { ARABIC_CHARSET, 1256},
  46. { GREEK_CHARSET, 1253},
  47. { TURKISH_CHARSET, 1254},
  48. { BALTIC_CHARSET, 1257},
  49. { EASTEUROPE_CHARSET, 1250},
  50. { RUSSIAN_CHARSET, 1251},
  51. { THAI_CHARSET, 874}
  52. };
  53. //
  54. // Functions
  55. // no font signature implemented
  56. //
  57. BOOL PrdTranslateCharsetInfo(
  58. IN UINT dwSrc,
  59. OUT LPCHARSETINFO lpCs,
  60. IN DWORD dwType)
  61. /*++
  62. Routine Description:
  63. Translate Character set to Codepage and vise versa.
  64. Arguments:
  65. dwSrc - Character set if dwType is TCI_SRCCHARSET
  66. Codepage if dwType is TCI_SRCCODEPAGE
  67. lpCs - Pointer to the CHARSETINFO
  68. dwType - a type of translation, TCI_SRCCHARSET and TCI_SRCCODEPAGE are
  69. currently supported.
  70. Return Value:
  71. TRUE if successful, FALSE if there is an error
  72. --*/
  73. {
  74. int i;
  75. switch( dwType ) {
  76. case TCI_SRCCHARSET:
  77. for( i = 0; i < NCHARSETS; i++ )
  78. if ( CharSetInfo[i].CharSet == dwSrc )
  79. {
  80. lpCs->ciACP = CharSetInfo[i].CodePage;
  81. lpCs->ciCharset = CharSetInfo[i].CharSet;
  82. //lpCs->fs.fsCsb[0] = fs[i];
  83. return TRUE;
  84. }
  85. break;
  86. case TCI_SRCCODEPAGE:
  87. for( i = 0; i < NCHARSETS; i++ )
  88. if ( CharSetInfo[i].CodePage == dwSrc )
  89. {
  90. lpCs->ciACP = CharSetInfo[i].CodePage;
  91. lpCs->ciCharset = CharSetInfo[i].CharSet;
  92. //lpCs->fs.fsCsb[0] = fs[i];
  93. return TRUE;
  94. }
  95. break;
  96. case TCI_SRCFONTSIG:
  97. default:
  98. break;
  99. }
  100. return(FALSE);
  101. }
  102. UINT PrdGetACP(VOID)
  103. /*++
  104. Routine Description:
  105. Get a current CodePage.
  106. Arguments:
  107. None
  108. Return Value:
  109. None
  110. --*/
  111. {
  112. USHORT OemCodePage, AnsiCodePage;
  113. EngGetCurrentCodePage(&OemCodePage, &AnsiCodePage);
  114. return (UINT)AnsiCodePage;
  115. }