OEMTranslate

<< Click to Display Table of Contents >>

Navigation:  Apollo VCL Components > Apollo VCL Component Reference > TApolloQuery > TApolloQuery Properties >

OEMTranslate

Applies to both TApolloQuery and TApolloTable.

Declaration

property OEMTranslate: WordBool;

Description

Enables automatic translation of data from OEM character set to Windows ANSI for the current table. This makes it possible to use an OEM table created under DOS with both DOS and Windows programs simultaneously. The table records and indexes will also be maintained in the OEM character set if OEMTranslate is set to True.

If True, data is translated from the OEM character set to ANSI after being read from the table. If True, the data is translated from ANSI back to OEM character set before writing to the table.

As long OEMTranslate is True, all key changes to indexes are translated to the OEM set before insertion. Also, search keys are translated into OEM before the search is undertaken. Translation is a seemless process.

European tables make heavy use of the upper end of the character set (values 128 to 255) to display characters with diacritical marks. If the table was created with a DOS program, these characters are not the same as their ANSI counterparts. The result is usually gibberish being displayed on the Windows screen.

image\tip.gif Take note, these operations are data dependent:

1) Some ASCII DOS characters cannot be translated.

2) There is a chance of ambiquous translation for many symbols under different languages (DOS ASCII has different Windows' ASCII pair under different locale)

3) Changes are not reversible.

image\tip.gif International developers accessing data from a CA-Clipper application should also see the OEMSORT.TXT file located in the root ..\VCL directory.

The setting applies to the current table only.

Permanent OEM to ANSI Translation

To permanently translate an OEM table to ANSI (i.e. no longer use the table in a DOS environment), use ApolloGetRecord and PutRecord in a read loop and toggle OEMTranslate on and off (True before the read, and False before the write). Ensure that the setting is False before closing as well.

Special Case: Upper() and Lower()

Both dBase and Clipper UPPER() and LOWER() case conversion functions limit the characters eligible for case conversion. With UPPER(), only characters a-z are converted to upper case. With LOWER(), only characters A-Z are converted.

Characters with diacritical marks are not converted when SDE_SP_SETLIMITCASECONV

switch is True if OEMTranslate is also set to True. To limit case conversion using this switch, set OEMTranslate to True and set the SysProp value on as well.  

 // To propertly translate Upper() and Lower() values

 ApTbl.OEMTranslate := True;

 ApTbl.SysProp( SDE_SP_SETLIMITCASECONV, Pointer(1));

 

To correctly convert characters with diacritical marks, set the correct locale on your Windows platform and do not use SDE_SP_SETLIMITCASECONV flag. However, in order for the index to be properly built and maintained, ensure that other DOS symbols for your data are correctly translated into Windows ASCII chars. In order to see what DOS symbols cannot be translated into Windows ASCII under your locale, you will need to refer to the Windows Platfrom SDK or run the Windows "Character Map" utility.

Delphi TApolloTable Examples

Example #1

procedure Form1.Button1Click(Sender: TObject);

begin

 // This is all you need to force DOS table translation 

 ApTbl.OEMTranslate := True; 

 ApTbl.Open; 

End;

Example #2

// Permanently convert OEM table to ANSI

procedure Form1.Button1Click(Sender: TObject);

var

 cpRec: Array[0..169]; // Record size

begin

 with ApTbl do 

 begin 

         // Enable fast processing 

                  ApTbl.Speedmode := True; 

         Open; 

         while not Eof do 

         begin 

                 OEMTranslate:= True;

                 ApolloGetRecord( cpRec ); 

                 OEMTranslat := False;

                 PutRecord( cpRec ); 

                 Skip( 1 ); 

         end; 

         Close; 

                  ApTbl.Speedmode := False; 

 end; 

end;

 

Delphi TApolloQuery Examples

procedure Form1.Button1Click(Sender: TObject);

begin

 with ApolloQuery1 do 

 begin 

         SQL := 'SELECT First, Last FROM Cust WHERE State = "CA"';

         OEMTranslate := True;

         Open; 

 end; 

end;

 

C++Builder TApolloTable Example

Example #1

void __fastcall TForm1::Button1Click(TObject * Sender)

{

         // This is all you need to force DOS table translation 

         ApTbl->OEMTranslate = true;

         ApTbl->Open();

}

Example #2

// Translate entire table to ANSI

void __fastcall TForm1::Button1Click(TObject * Sender)

{

 char cpRec[170]; // Record size

 

 ApTbl->Open(); 

 while (!ApTbl->Eof()) 

 

         // Enable fast processing 

                  ApTbl->Speedmode = true; 

         ApTbl->OEMTranslate = true;

         ApTbl->ApolloGetRecord( cpRec ); 

         ApTbl->OEMTranslate = false;

         ApTbl->PutRecord( cpRec ); 

         ApTbl->Skip( 1 ); 

 

 ApTbl->Close(); 

 ApTbl->Speedmode = false; 

}

C++Builder TApolloQuery Example

void __fastcall TForm1::Button1Click(TObject * Sender)

{

 ApolloQuery->SQL = "SELECT First, Last FROM Cust WHERE State = 'CA'";

 ApolloQuery->OEMTranslate = TRUE;

 ApolloQuery->Open(); 

}