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.

110 lines
2.3 KiB

  1. /*
  2. Copyright (c) 1997-1999 Microsoft Corporation
  3. Module Name:
  4. sdpcset.h
  5. Abstract:
  6. Author:
  7. */
  8. #ifndef __SDP_CHARACTER_SET__
  9. #define __SDP_CHARACTER_SET__
  10. // for code pages etc.
  11. #include <winnls.h>
  12. const CHAR SDP_CHARACTER_SET_STRING[] = "\na=charset:";
  13. const USHORT SDP_CHARACTER_SET_STRLEN = (USHORT) strlen(SDP_CHARACTER_SET_STRING);
  14. const CHAR ASCII_STRING[] = "ascii";
  15. const USHORT ASCII_STRLEN = (USHORT) strlen(ASCII_STRING);
  16. const CHAR UTF7_STRING[] = "unicode-1-1-utf7";
  17. const USHORT UTF7_STRLEN = (USHORT) strlen(UTF7_STRING);
  18. const CHAR UTF8_STRING[] = "unicode-1-1-utf8";
  19. const USHORT UTF8_STRLEN = (USHORT) strlen(UTF8_STRING);
  20. enum SDP_CHARACTER_SET
  21. {
  22. CS_IMPLICIT, // implicit from the sdp
  23. CS_ASCII, // 8bit ISO 8859-1
  24. CS_UTF7, // unicode, ISO 10646, UTF-7 encoding (rfc 1642)
  25. CS_UTF8, // unicode, UTF-8 encoding
  26. CS_INVALID // invalid character set
  27. };
  28. struct SDP_CHARACTER_SET_ENTRY
  29. {
  30. SDP_CHARACTER_SET m_CharSetCode;
  31. const CHAR *m_CharSetString;
  32. USHORT m_Length;
  33. };
  34. const SDP_CHARACTER_SET_ENTRY SDP_CHARACTER_SET_TABLE[] = {
  35. {CS_UTF7, UTF7_STRING, UTF7_STRLEN},
  36. {CS_UTF8, UTF8_STRING, UTF8_STRLEN},
  37. {CS_ASCII, ASCII_STRING, ASCII_STRLEN}
  38. };
  39. const USHORT NUM_SDP_CHARACTER_SET_ENTRIES = sizeof(SDP_CHARACTER_SET_TABLE)/sizeof(SDP_CHARACTER_SET_ENTRY);
  40. inline BOOL
  41. IsLegalCharacterSet(
  42. IN SDP_CHARACTER_SET CharacterSet,
  43. IN OUT UINT *CodePage = NULL
  44. )
  45. {
  46. switch(CharacterSet)
  47. {
  48. case CS_ASCII:
  49. {
  50. if ( NULL != CodePage )
  51. *CodePage = CP_ACP;
  52. }
  53. break;
  54. case CS_UTF7:
  55. {
  56. if ( NULL != CodePage )
  57. *CodePage = CP_UTF7;
  58. }
  59. break;
  60. case CS_UTF8:
  61. {
  62. if ( NULL != CodePage )
  63. *CodePage = CP_UTF8;
  64. }
  65. break;
  66. default:
  67. {
  68. return FALSE;
  69. }
  70. }
  71. return TRUE;
  72. }
  73. #endif // __SDP_CHARACTER_SET__