少年修仙传客户端基础资源
hch
2024-04-01 d01413b00ef631ac20347716b23818b0b811f65f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#include "il2cpp-config.h"
 
#if !IL2CPP_TINY_WITHOUT_DEBUGGER
 
#include "VmStringUtils.h"
#include "il2cpp-object-internals.h"
#include "../char-conversions.h"
#include "utils/Functional.h"
#include "utils/StringUtils.h"
#include "utils/utf8-cpp/source/utf8/unchecked.h"
 
namespace il2cpp
{
namespace utils
{
    Il2CppChar VmStringUtils::Utf16ToLower(Il2CppChar c)
    {
        const Il2CppChar kDataLowThreshold = 9423;
        const Il2CppChar kDataHighThreshold = 65313;
 
        if (c <= kDataLowThreshold)
        {
            c = ToLowerDataLow[c];
        }
        else if (c >= kDataHighThreshold)
        {
            c = ToLowerDataHigh[c - kDataHighThreshold];
        }
 
        return c;
    }
 
    bool VmStringUtils::CaseSensitiveComparer::operator()(const std::string& left, const std::string& right) const
    {
        return left == right;
    }
 
    bool VmStringUtils::CaseSensitiveComparer::operator()(const std::string& left, const char* right) const
    {
        return left.compare(right) == 0;
    }
 
    bool VmStringUtils::CaseSensitiveComparer::operator()(const char* left, const std::string& right) const
    {
        return right.compare(left) == 0;
    }
 
    bool VmStringUtils::CaseSensitiveComparer::operator()(const char* left, const char* right) const
    {
        return strcmp(left, right) == 0;
    }
 
    static inline void Utf32CharToSurrogatePair(uint32_t c, Il2CppChar(&surrogatePair)[2])
    {
        const Il2CppChar kLeadOffset = 55232;
        const Il2CppChar kTrailSurrogateMin = 56320;
 
        if (c > 0xffff)
        {
            surrogatePair[0] = static_cast<Il2CppChar>((c >> 10) + kLeadOffset);
            surrogatePair[1] = static_cast<Il2CppChar>((c & 0x3ff) + kTrailSurrogateMin);
        }
        else
        {
            surrogatePair[0] = static_cast<Il2CppChar>(c);
            surrogatePair[1] = 0;
        }
    }
 
    static inline bool Utf16CharEqualsIgnoreCase(Il2CppChar left, Il2CppChar right)
    {
        return VmStringUtils::Utf16ToLower(left) == VmStringUtils::Utf16ToLower(right);
    }
 
    bool VmStringUtils::CaseInsensitiveComparer::operator()(const std::string& left, const std::string& right) const
    {
        return operator()(left.c_str(), right.c_str());
    }
 
    bool VmStringUtils::CaseInsensitiveComparer::operator()(const std::string& left, const char* right) const
    {
        return operator()(left.c_str(), right);
    }
 
    bool VmStringUtils::CaseInsensitiveComparer::operator()(const char* left, const std::string& right) const
    {
        return operator()(left, right.c_str());
    }
 
    bool VmStringUtils::CaseInsensitiveComparer::operator()(const char* left, const char* right) const
    {
#if IL2CPP_DEBUG    // Invalid UTF8 strings shouldn't be passed here, so let's assert in debug mode
        IL2CPP_ASSERT(utf8::is_valid(left, left + strlen(left)));
        IL2CPP_ASSERT(utf8::is_valid(right, right + strlen(right)));
#endif
 
        Il2CppChar utf16Left[2];
        Il2CppChar utf16Right[2];
 
        while (*left && *right)
        {
            Utf32CharToSurrogatePair(utf8::unchecked::next(left), utf16Left);
            Utf32CharToSurrogatePair(utf8::unchecked::next(right), utf16Right);
 
            if (!Utf16CharEqualsIgnoreCase(utf16Left[0], utf16Right[0]) ||
                !Utf16CharEqualsIgnoreCase(utf16Left[1], utf16Right[1]))
            {
                return false;
            }
        }
 
        return *left == '\0' && *right == '\0';
    }
 
    bool VmStringUtils::CaseSensitiveEquals(Il2CppString* left, const char* right)
    {
        std::string leftString = StringUtils::Utf16ToUtf8(left->chars);
        functional::Filter<const char*, CaseSensitiveComparer> equalsLeft(leftString.c_str());
        return equalsLeft(right);
    }
 
    bool VmStringUtils::CaseSensitiveEquals(const char* left, const char* right)
    {
        functional::Filter<const char*, CaseSensitiveComparer> equalsLeft(left);
        return equalsLeft(right);
    }
 
    bool VmStringUtils::CaseInsensitiveEquals(Il2CppString* left, const char* right)
    {
        std::string leftString = StringUtils::Utf16ToUtf8(left->chars);
        functional::Filter<const char*, CaseInsensitiveComparer> equalsLeft(leftString.c_str());
        return equalsLeft(right);
    }
 
    bool VmStringUtils::CaseInsensitiveEquals(const char* left, const char* right)
    {
        functional::Filter<const char *, CaseInsensitiveComparer> equalsLeft(left);
        return equalsLeft(right);
    }
}
}
 
#endif