MCPcopy Create free account
hub / github.com/9chu/LuaSTGPlus / operator()

Method operator()

LuaSTGPlus/UnicodeStringEncoding.cpp:88–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86 char16_t m_leadChar = 0;
87public:
88 bool operator() (uint8_t input, char32_t& output)
89 {
90 // ״̬��
91 switch (m_iState)
92 {
93 case 0:
94 m_cBuf[0] = input;
95 m_iState = 1;
96 return false;
97 case 1:
98 m_cBuf[1] = input;
99 *(uint8_t*)&m_leadChar = m_cBuf[0];
100 *((uint8_t*)&m_leadChar + 1) = m_cBuf[1];
101 // ����Ƿ�Ϊ����λ
102 if (m_leadChar >= 0xD800u && m_leadChar < 0xDC00)
103 {
104 m_leadChar -= 0xD800u;
105 m_iState = 2;
106 return false;
107 }
108 else
109 {
110 output = static_cast<char32_t>(m_leadChar);
111 m_iState = 0;
112 return true;
113 }
114 case 2:
115 m_cBuf[0] = input;
116 m_iState = 3;
117 return false;
118 case 3:
119 m_cBuf[1] = input;
120 {
121 char16_t tempChar;
122 *(uint8_t*)&tempChar = m_cBuf[0];
123 *((uint8_t*)&tempChar + 1) = m_cBuf[1];
124 // ��ϲ����
125 if (tempChar >= 0xDC00u && tempChar < 0xE000)
126 {
127 output = static_cast<char32_t>((m_leadChar << 16) | (tempChar - 0xDC00u));
128 m_iState = 0;
129 return true;
130 }
131 else
132 {
133 output = (char32_t)'?';
134 m_iState = 0;
135 return true;
136 }
137 }
138 default:
139 output = (char32_t)'?';
140 m_iState = 0;
141 return true;
142 }
143 }
144};
145

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected