Unicode.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //
  2. // Unicode.cpp
  3. //
  4. // $Id: //poco/1.4/Foundation/src/Unicode.cpp#2 $
  5. //
  6. // Library: Foundation
  7. // Package: Text
  8. // Module: Unicode
  9. //
  10. // Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
  11. // and Contributors.
  12. //
  13. // SPDX-License-Identifier: BSL-1.0
  14. //
  15. #include "Poco/Unicode.h"
  16. extern "C"
  17. {
  18. #include "pcre_config.h"
  19. GCC_DIAG_OFF(unused-function) // pcre_memmove unused function warning
  20. #include "pcre_internal.h"
  21. }
  22. namespace Poco {
  23. void Unicode::properties(int ch, CharacterProperties& props)
  24. {
  25. if (ch > UCP_MAX_CODEPOINT) ch = 0;
  26. const ucd_record* ucd = GET_UCD(ch);
  27. props.category = static_cast<CharacterCategory>(_pcre_ucp_gentype[ucd->chartype]);
  28. props.type = static_cast<CharacterType>(ucd->chartype);
  29. props.script = static_cast<Script>(ucd->script);
  30. }
  31. int Unicode::toLower(int ch)
  32. {
  33. if (isUpper(ch))
  34. return static_cast<int>(UCD_OTHERCASE(static_cast<unsigned>(ch)));
  35. else
  36. return ch;
  37. }
  38. int Unicode::toUpper(int ch)
  39. {
  40. if (isLower(ch))
  41. return static_cast<int>(UCD_OTHERCASE(static_cast<unsigned>(ch)));
  42. else
  43. return ch;
  44. }
  45. } // namespace Poco