encoding_group.hxx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /** Enum type for supporting encodings in libpqxx
  2. *
  3. * Copyright (c) 2000-2022, Jeroen T. Vermeulen.
  4. *
  5. * See COPYING for copyright license. If you did not receive a file called
  6. * COPYING with this source code, please notify the distributor of this
  7. * mistake, or contact the author.
  8. */
  9. #ifndef PQXX_H_ENCODING_GROUP
  10. #define PQXX_H_ENCODING_GROUP
  11. #include <cstddef>
  12. namespace pqxx::internal
  13. {
  14. // Types of encodings supported by PostgreSQL, see
  15. // https://www.postgresql.org/docs/current/static/multibyte.html#CHARSET-TABLE
  16. enum class encoding_group
  17. {
  18. // Handles all single-byte fixed-width encodings
  19. MONOBYTE,
  20. // Multibyte encodings.
  21. // Many of these can embed ASCII-like bytes inside multibyte characters,
  22. // notably Big5, SJIS, SHIFT_JIS_2004, GP18030, GBK, JOHAB, UHC.
  23. BIG5,
  24. EUC_CN,
  25. // TODO: Merge EUC_JP and EUC_JIS_2004?
  26. EUC_JP,
  27. EUC_JIS_2004,
  28. EUC_KR,
  29. EUC_TW,
  30. GB18030,
  31. GBK,
  32. JOHAB,
  33. MULE_INTERNAL,
  34. // TODO: Merge SJIS and SHIFT_JIS_2004?
  35. SJIS,
  36. SHIFT_JIS_2004,
  37. UHC,
  38. UTF8,
  39. };
  40. // TODO:: Can we just use string_view now?
  41. /// Function type: "find the end of the current glyph."
  42. /** This type of function takes a text buffer, and a location in that buffer,
  43. * and returns the location one byte past the end of the current glyph.
  44. *
  45. * The start offset marks the beginning of the current glyph. It must fall
  46. * within the buffer.
  47. *
  48. * There are multiple different glyph scanner implementations, for different
  49. * kinds of encodings.
  50. */
  51. using glyph_scanner_func =
  52. std::size_t(char const buffer[], std::size_t buffer_len, std::size_t start);
  53. } // namespace pqxx::internal
  54. #endif