Skip to content

Commit d439a6e

Browse files
committed
GetUTF8CharCode
1 parent 6d340fd commit d439a6e

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/Engine/Fonts_Z.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,28 @@ S32 GetUTF8CharBytes(const S8* a1)
1313
}
1414
return 1;
1515
}
16+
17+
U32 GetUTF8CharCode(const S8* a1)
18+
{
19+
const U8 *p = (const U8*)a1;
20+
char v1 = *p;
21+
22+
if ((v1 & 0x80) == 0)
23+
{
24+
return p[0];
25+
}
26+
else if ((v1 & 0xE0) == 0xC0)
27+
{
28+
return ((p[0] & 0xff) << 8) | (p[1] & 0xff);
29+
}
30+
else if ((v1 & 0xF0) == 0xE0)
31+
{
32+
return ((p[0] & 0xff) << 16) | ((p[1] & 0xff) << 8) | (p[2] & 0xff);
33+
}
34+
else if ((v1 & 0xF8) == 0xF0)
35+
{
36+
return ((p[0] & 0xff) << 24) | ((p[1] & 0xff) << 16) | ((p[2] & 0xff) << 8) | (p[3] & 0xff);
37+
}
38+
39+
return 1;
40+
}

src/Engine/includes/Fonts_Z.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
#include "Types_Z.h"
44

55
S32 GetUTF8CharBytes(const S8* a1);
6-
6+
U32 GetUTF8CharCode(const S8* a1);
77
#endif

0 commit comments

Comments
 (0)