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