Skip to content

Commit

Permalink
Added ccompare to ICU
Browse files Browse the repository at this point in the history
  • Loading branch information
crimean committed Jan 28, 2017
1 parent 6bf126c commit a2aa11f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/OsmAndCore/ICU.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ namespace OsmAnd
OSMAND_CORE_API bool OSMAND_CORE_CALL ccontains(const QString& _base, const QString& _part);
OSMAND_CORE_API bool OSMAND_CORE_CALL cstartsWith(const QString& _searchInParam, const QString& _theStart,
bool checkBeginning, bool checkSpaces, bool equals);
OSMAND_CORE_API int OSMAND_CORE_CALL ccompare(const QString& _base, const QString& _part);
}
}

Expand Down
22 changes: 22 additions & 0 deletions src/ICU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,3 +518,25 @@ OSMAND_CORE_API bool OSMAND_CORE_CALL OsmAnd::ICU::cstartsWith(const QString& _s
return result;
}

OSMAND_CORE_API int OSMAND_CORE_CALL OsmAnd::ICU::ccompare(const QString& _s1, const QString& _s2)
{
UErrorCode icuError = U_ZERO_ERROR;
int result = 0;
const auto collator = g_pIcuCollator->clone();
if (collator == nullptr || U_FAILURE(icuError))
{
LogPrintf(LogSeverityLevel::Error, "ICU error: %d", icuError);
if (collator != nullptr)
delete collator;
return result;
}
else
{
UnicodeString s1 = qStrToUniStr(_s1);
UnicodeString s2 = qStrToUniStr(_s2);
result = collator->compare(s1, s2);
}
if (collator != nullptr)
delete collator;
return result;
}

0 comments on commit a2aa11f

Please sign in to comment.