FireBirdLib - Topfield TMS PVR TAP Programming Library
StrToISO.c
Go to the documentation of this file.
1#include <string.h>
2#include "libFireBird.h"
3
4void StrToISO(const byte *SourceString, byte *DestString)
5{
7
8 int Len;
9 bool hasAnsiChars, hasUTFChars;
10 byte BytesPerCharacter;
11 dword UTF32;
12
13 if(!SourceString || !DestString)
14 {
15 TRACEEXIT();
16 return;
17 }
18
19 if(!*SourceString)
20 {
21 *DestString = '\0';
22
23 TRACEEXIT();
24 return;
25 }
26
27 GetStringEncoding(SourceString, &hasAnsiChars, &hasUTFChars);
28
29 if(!hasAnsiChars && hasUTFChars)
30 {
31 Len = strlen(SourceString);
32 while(Len > 0)
33 {
34 UTF32 = UTF8ToUTF32(SourceString, &BytesPerCharacter);
35
36 if(UTF32 > 0xff)
37 {
38 //LogEntryFBLibPrintf(TRUE, "StrToISO: character 0x%4.4lx ignored", UTF32);
39 }
40 else
41 {
42 *DestString = UTF32 & 0xff;
43 DestString++;
44 }
45
46 SourceString += BytesPerCharacter;
47
48 Len -= BytesPerCharacter;
49 }
50 *DestString = '\0';
51 }
52 else
53 strcpy(DestString, SourceString);
54
55 TRACEEXIT();
56}
void StrToISO(const byte *SourceString, byte *DestString)
Definition: StrToISO.c:4
#define TRACEEXIT()
Definition: libFireBird.h:1244
void GetStringEncoding(const char *Text, bool *hasAnsiChars, bool *hasUTFChars)
#define TRACEENTER()
Definition: libFireBird.h:1243
dword UTF8ToUTF32(const byte *UTF8Character, byte *BytesPerChar)
Definition: UTF8ToUTF32.c:3