FireBirdLib - Topfield TMS PVR TAP Programming Library
isUTF8Char.c
Go to the documentation of this file.
1#include "libFireBird.h"
2
3bool isUTF8Char(const byte *p, byte *BytesPerChar)
4{
6
7 bool a, b, c;
8 byte bpc;
9
10 if(!p)
11 {
12 if(BytesPerChar) *BytesPerChar = 1;
13
14 TRACEEXIT();
15 return FALSE;
16 }
17
18 bpc = 1;
19
20 a = ((p[0] & 0xe0) == 0xc0) && ((p[1] & 0xc0) == 0x80);
21 if(a) bpc = 2;
22
23 b = ((p[0] & 0xf0) == 0xe0) && ((p[1] & 0xc0) == 0x80) && ((p[2] & 0xc0) == 0x80);
24 if(b) bpc = 3;
25
26 c = ((p[0] & 0xf8) == 0xf0) && ((p[1] & 0xc0) == 0x80) && ((p[2] & 0xc0) == 0x80) && ((p[3] & 0xc0) == 0x80);
27 if(c) bpc = 4;
28
29 if(BytesPerChar) *BytesPerChar = bpc;
30
31 TRACEEXIT();
32 return (a || b || c);
33}
bool isUTF8Char(const byte *p, byte *BytesPerChar)
Definition: isUTF8Char.c:3
#define TRACEEXIT()
Definition: libFireBird.h:1244
#define TRACEENTER()
Definition: libFireBird.h:1243