Skip to content

Commit

Permalink
Added optional conversion from Latin-1 to UTF8 (UTF8ToDB)
Browse files Browse the repository at this point in the history
20190320	mvh	Added conversion from ISO_IR 100 to UTF8 in MakeSafeStringValues
			Setting UTF8ToDB default 0 for now

Note: a full support of DICOM character sets is out of scope
  • Loading branch information
marcelvanherk committed Mar 20, 2019
1 parent eb7502b commit 81fe030
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
Binary file modified install32/dgate.exe
Binary file not shown.
Binary file modified install64/dgate64.exe
Binary file not shown.
27 changes: 20 additions & 7 deletions src/dgate/src/dbsql.cpp
Expand Up @@ -227,6 +227,8 @@ Spectra0015: Thu, 6 Mar 2014 15:34:35 -0300: Fix mismatched new/delete in dbsql.
20170419 mvh Fixed merging code (MergeUIDs), added stage (merge) if stage in database
20171010 mvh Fix case of database table names
20171122 mvh Added DT_ISTR (case insensitive query string)
20190320 mvh Added conversion from ISO_IR 100 to UTF8 in MakeSafeStringValues
Setting UTF8ToDB default 0 for now
*/

#define NCACHE 256
Expand Down Expand Up @@ -336,8 +338,9 @@ static int MaxFieldLength=0;
static int FixPhilips=0;
static int AllowEmptyPatientID=0;
int FixKodak=0;
int DoubleBackSlashToDB=0;
int UseEscapeStringConstants=0;
int DoubleBackSlashToDB=0;
int UTF8ToDB=0;

int FileCompressMode=0;
char PatientQuerySortOrder[256]="";
Expand Down Expand Up @@ -388,6 +391,10 @@ ConfigDBSpecials(void)
(char*) Temp, 128, ConfigFile);
DoubleBackSlashToDB = atoi(Temp);

MyGetPrivateProfileString ( RootSC, "UTF8ToDB", "0",
(char*) Temp, 128, ConfigFile);
UTF8ToDB = atoi(Temp);

MyGetPrivateProfileString ( RootSC, "UseEscapeStringConstants", "0",
(char*) Temp, 128, ConfigFile);
UseEscapeStringConstants = atoi(Temp);
Expand Down Expand Up @@ -2359,8 +2366,8 @@ MakeSafeStringValues (
char *string )
{
unsigned int Length;
char *sout;
char *sin;
unsigned char *sout;
unsigned char *sin;
char *s;
UINT Index;

Expand All @@ -2372,8 +2379,8 @@ MakeSafeStringValues (

s = SetString(vr, NULL, 0);
Length = strlen(s);
sin = (char*)s;
sout = string;
sin = (unsigned char *)s;
sout = (unsigned char *)string;

if (UseEscapeStringConstants)
if (strchr(s, '\\'))
Expand All @@ -2383,8 +2390,14 @@ MakeSafeStringValues (

Index = 0;
while(Index < Length)
{
switch (*sin)
{ // Convert to UTF-8, assuming ISO_IR 100 for now (ISO/IEC 8859-1 = Latin-1)
if (UTF8ToDB && (*sin&128))
{
*sout++=0xc2+(*sin>0xbf);
*sout++=(*sin++&0x3f)+0x80;
}

else switch (*sin)
{
case '\'':
(*sout) = '\'';++sout;
Expand Down

0 comments on commit 81fe030

Please sign in to comment.