2012-04-29 18:52:25 +00:00
|
|
|
//
|
|
|
|
// Unicode.cpp
|
|
|
|
//
|
|
|
|
// Library: Foundation
|
|
|
|
// Package: Text
|
|
|
|
// Module: Unicode
|
|
|
|
//
|
|
|
|
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
|
|
|
// and Contributors.
|
|
|
|
//
|
2014-05-04 21:02:42 +02:00
|
|
|
// SPDX-License-Identifier: BSL-1.0
|
2012-04-29 18:52:25 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#include "Poco/Unicode.h"
|
|
|
|
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
{
|
2022-07-06 17:46:38 +02:00
|
|
|
#include "pcre2_config.h"
|
|
|
|
#include "pcre2_internal.h"
|
2012-04-29 18:52:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
namespace Poco {
|
|
|
|
|
|
|
|
|
|
|
|
void Unicode::properties(int ch, CharacterProperties& props)
|
|
|
|
{
|
2012-11-10 11:44:44 +01:00
|
|
|
if (ch > UCP_MAX_CODEPOINT) ch = 0;
|
2012-04-29 18:52:25 +00:00
|
|
|
const ucd_record* ucd = GET_UCD(ch);
|
2022-07-06 17:46:38 +02:00
|
|
|
props.category = static_cast<CharacterCategory>(PRIV(ucp_gentype_8)[ucd->chartype]);
|
2012-04-29 18:52:25 +00:00
|
|
|
props.type = static_cast<CharacterType>(ucd->chartype);
|
|
|
|
props.script = static_cast<Script>(ucd->script);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Unicode::toLower(int ch)
|
|
|
|
{
|
|
|
|
if (isUpper(ch))
|
|
|
|
return static_cast<int>(UCD_OTHERCASE(static_cast<unsigned>(ch)));
|
|
|
|
else
|
|
|
|
return ch;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Unicode::toUpper(int ch)
|
|
|
|
{
|
|
|
|
if (isLower(ch))
|
|
|
|
return static_cast<int>(UCD_OTHERCASE(static_cast<unsigned>(ch)));
|
|
|
|
else
|
|
|
|
return ch;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace Poco
|