Replace MacRoman conversion with LIBICONV implementation

This commit is contained in:
elasota
2020-01-05 03:55:35 -05:00
parent 1e3cf76bf3
commit 7c4ec4a467
17 changed files with 136 additions and 730 deletions

View File

@@ -1,11 +1,23 @@
#include "PLStringCompare.h"
#include "MacRoman.h"
#include "MacRomanConversion.h"
#include <string.h>
#include <algorithm>
namespace
{
static uint8_t ToLowerInvariant(uint8_t v)
{
// This isn't very comprehensive, but we're only ever using this for two cases that don't contain any diacritics or anything
if (v >= 65 && v <= 90)
return v + 32;
else
return v;
}
}
namespace StrCmp
{
{
int Compare(const PLPasStr &string1, const PLPasStr &string2)
{
const uint8_t *chars1 = string1.UChars();
@@ -41,8 +53,8 @@ namespace StrCmp
for (size_t i = 0; i < shorterLen; i++)
{
const uint8_t c1 = PortabilityLayer::MacRoman::g_toLower[chars1[i]];
const uint8_t c2 = PortabilityLayer::MacRoman::g_toLower[chars2[i]];
const uint8_t c1 = ToLowerInvariant(chars1[i]);
const uint8_t c2 = ToLowerInvariant(chars2[i]);
if (c1 < c2)
return -1;