UTF32Encoding.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. //
  2. // UTF32Encoding.h
  3. //
  4. // $Id: //poco/1.4/Foundation/include/Poco/UTF32Encoding.h#1 $
  5. //
  6. // Library: Foundation
  7. // Package: Text
  8. // Module: UTF32Encoding
  9. //
  10. // Definition of the UTF32Encoding class.
  11. //
  12. // Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
  13. // and Contributors.
  14. //
  15. // SPDX-License-Identifier: BSL-1.0
  16. //
  17. #ifndef Foundation_UTF32Encoding_INCLUDED
  18. #define Foundation_UTF32Encoding_INCLUDED
  19. #include "Poco/Foundation.h"
  20. #include "Poco/TextEncoding.h"
  21. namespace Poco {
  22. class Foundation_API UTF32Encoding: public TextEncoding
  23. /// UTF-32 text encoding, as defined in RFC 2781.
  24. ///
  25. /// When converting from UTF-32 to Unicode, surrogates are
  26. /// reported as they are - in other words, surrogate pairs
  27. /// are not combined into one Unicode character.
  28. {
  29. public:
  30. enum ByteOrderType
  31. {
  32. BIG_ENDIAN_BYTE_ORDER,
  33. LITTLE_ENDIAN_BYTE_ORDER,
  34. NATIVE_BYTE_ORDER
  35. };
  36. UTF32Encoding(ByteOrderType byteOrder = NATIVE_BYTE_ORDER);
  37. /// Creates and initializes the encoding for the given byte order.
  38. UTF32Encoding(int byteOrderMark);
  39. /// Creates and initializes the encoding for the byte-order
  40. /// indicated by the given byte-order mark, which is the Unicode
  41. /// character 0xFEFF.
  42. ~UTF32Encoding();
  43. ByteOrderType getByteOrder() const;
  44. /// Returns the byte-order currently in use.
  45. void setByteOrder(ByteOrderType byteOrder);
  46. /// Sets the byte order.
  47. void setByteOrder(int byteOrderMark);
  48. /// Sets the byte order according to the given
  49. /// byte order mark, which is the Unicode
  50. /// character 0xFEFF.
  51. const char* canonicalName() const;
  52. bool isA(const std::string& encodingName) const;
  53. const CharacterMap& characterMap() const;
  54. int convert(const unsigned char* bytes) const;
  55. int convert(int ch, unsigned char* bytes, int length) const;
  56. int queryConvert(const unsigned char* bytes, int length) const;
  57. int sequenceLength(const unsigned char* bytes, int length) const;
  58. private:
  59. bool _flipBytes;
  60. static const char* _names[];
  61. static const CharacterMap _charMap;
  62. };
  63. } // namespace Poco
  64. #endif // Foundation_UTF32Encoding_INCLUDED