UTF32Encoding.h 2.0 KB

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