147 {
148 char c = '\0';
149 if (encoder != null)
150 {
152 }
154 while (true)
155 {
156 if (encodingByteBuffer.MoreData)
157 {
158 char nextChar = encodingByteBuffer.GetNextChar();
159 if (c != 0)
160 {
161 if (!char.IsLowSurrogate(nextChar))
162 {
163 encodingByteBuffer.MovePrevious(bThrow: false);
164 if (encodingByteBuffer.Fallback(c))
165 {
166 c = '\0';
167 continue;
168 }
169 c = '\0';
170 }
171 else
172 {
173 int num = (c - 55296 << 10) + (nextChar - 56320);
174 byte b = (byte)(num % 10 + 48);
175 num /= 10;
176 byte b2 = (byte)(num % 126 + 129);
177 num /= 126;
178 byte b3 = (byte)(num % 10 + 48);
179 num /= 10;
180 c = '\0';
181 if (encodingByteBuffer.AddByte((byte)(num + 144), b3, b2, b))
182 {
183 c = '\0';
184 continue;
185 }
186 encodingByteBuffer.MovePrevious(bThrow: false);
187 }
188 }
189 else if (nextChar <= '\u007f')
190 {
191 if (encodingByteBuffer.AddByte((byte)nextChar))
192 {
193 continue;
194 }
195 }
196 else
197 {
198 if (char.IsHighSurrogate(nextChar))
199 {
200 c = nextChar;
201 continue;
202 }
203 if (char.IsLowSurrogate(nextChar))
204 {
205 if (encodingByteBuffer.Fallback(nextChar))
206 {
207 continue;
208 }
209 }
210 else
211 {
214 {
215 byte b4 = (byte)(num2 % 10 + 48);
216 num2 /= 10;
217 byte b5 = (byte)(num2 % 126 + 129);
218 num2 /= 126;
219 byte b6 = (byte)(num2 % 10 + 48);
220 num2 /= 10;
221 if (encodingByteBuffer.AddByte((byte)(num2 + 129), b6, b5, b4))
222 {
223 continue;
224 }
225 }
226 else if (encodingByteBuffer.AddByte((byte)(num2 >> 8), (byte)(num2 & 0xFFu)))
227 {
228 continue;
229 }
230 }
231 }
232 }
233 if ((encoder !=
null && !encoder.
MustFlush) || c <=
'\0')
234 {
235 break;
236 }
237 encodingByteBuffer.Fallback(c);
238 c = '\0';
239 }
240 if (encoder != null)
241 {
243 {
244 encoder.charLeftOver = c;
245 }
246 encoder.m_charsUsed = encodingByteBuffer.CharsUsed;
247 }
248 return encodingByteBuffer.Count;
249 }
unsafe ushort * mapUnicodeToBytes
unsafe bool Is4Byte(char charTest)