Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ GetUTF8ByteCount() [2/3]

static unsafe int System.Reflection.BlobUtilities.GetUTF8ByteCount ( char * str,
int charCount,
int byteLimit,
out char * remainder )
inlinestaticpackage

Definition at line 210 of file BlobUtilities.cs.

211 {
212 char* ptr = str + charCount;
213 char* ptr2 = str;
214 int num = 0;
215 while (ptr2 < ptr)
216 {
217 char c = *(ptr2++);
218 int num2;
219 if (c < '\u0080')
220 {
221 num2 = 1;
222 }
223 else if (c < 'ࠀ')
224 {
225 num2 = 2;
226 }
227 else if (IsHighSurrogateChar(c) && ptr2 < ptr && IsLowSurrogateChar(*ptr2))
228 {
229 num2 = 4;
230 ptr2++;
231 }
232 else
233 {
234 num2 = 3;
235 }
236 if (num + num2 > byteLimit)
237 {
238 ptr2 -= ((num2 < 4) ? 1 : 2);
239 break;
240 }
241 num += num2;
242 }
243 remainder = ptr2;
244 return num;
245 }
static bool IsLowSurrogateChar(int c)
static bool IsHighSurrogateChar(int c)

References System.charCount, System.Reflection.BlobUtilities.IsHighSurrogateChar(), System.Reflection.BlobUtilities.IsLowSurrogateChar(), and System.str.