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.

72 lines
2.1 KiB

  1. /*
  2. * @(#)CharEncoder.hxx 1.0 6/10/97
  3. *
  4. * Copyright (c) 1997 - 1999 Microsoft Corporation. All rights reserved. *
  5. */
  6. #ifndef _FUSION_XMLPARSER__CHARENCODER_HXX
  7. #define _FUSION_XMLPARSER__CHARENCODER_HXX
  8. #pragma once
  9. #include "codepage.h"
  10. typedef HRESULT WideCharFromMultiByteFunc(DWORD* pdwMode, CODEPAGE codepage, BYTE * bytebuffer,
  11. UINT * cb, WCHAR * buffer, UINT * cch);
  12. struct EncodingEntry
  13. {
  14. UINT codepage;
  15. WCHAR * charset;
  16. UINT maxCharSize;
  17. WideCharFromMultiByteFunc * pfnWideCharFromMultiByte;
  18. };
  19. class Encoding
  20. {
  21. protected:
  22. Encoding() {};
  23. public:
  24. // default encoding is UTF-8.
  25. static Encoding* newEncoding(const WCHAR * s, ULONG len, bool endian, bool mark);
  26. virtual ~Encoding();
  27. WCHAR * charset; // charset
  28. bool littleendian; // endian flag for UCS-2/UTF-16 encoding, true: little endian, false: big endian
  29. bool byteOrderMark; // byte order mark (BOM) flag, BOM appears when true
  30. };
  31. /**
  32. *
  33. * An Encoder specifically for dealing with different encoding formats
  34. * @version 1.0, 6/10/97
  35. */
  36. class NOVTABLE CharEncoder
  37. {
  38. //
  39. // class CharEncoder is a utility class, makes sure no instance can be defined
  40. //
  41. private: virtual charEncoder() = 0;
  42. public:
  43. static HRESULT getWideCharFromMultiByteInfo(Encoding * encoding, CODEPAGE * pcodepage, WideCharFromMultiByteFunc ** pfnWideCharFromMultiByte, UINT * mCharSize);
  44. /**
  45. * Encoding functions: get Unicode from other encodings
  46. */
  47. // actually, we only use these three functions for UCS-2 and UTF-8
  48. static WideCharFromMultiByteFunc wideCharFromUtf8;
  49. static WideCharFromMultiByteFunc wideCharFromUcs2Bigendian;
  50. static WideCharFromMultiByteFunc wideCharFromUcs2Littleendian;
  51. /**
  52. * Encoding functions: from Unicode to other encodings
  53. */
  54. static int getCharsetInfo(const WCHAR * charset, CODEPAGE * pcodepage, UINT * mCharSize);
  55. private:
  56. static const EncodingEntry charsetInfo [];
  57. };
  58. #endif _FUSION_XMLPARSER__CHARENCODER_HXX