|
@@ -123,7 +123,7 @@ const
|
|
|
DbfLocale_Bul868 = $020000;
|
|
|
|
|
|
//*************************************************************************//
|
|
|
-// DB3/DB4/FoxPro/Visual Foxpro Language ID to CodePage conversion table
|
|
|
+// DB3/DB4/FoxPro Language ID to CodePage conversion table
|
|
|
// Visual FoxPro docs call language ID "code page mark"
|
|
|
// or "code page identifier"
|
|
|
//*************************************************************************//
|
|
@@ -165,6 +165,7 @@ const
|
|
|
{F0} 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
{F8} 0, 0, 0, 0, 0, 0, 0, 0);
|
|
|
|
|
|
+
|
|
|
{$ifdef FPC_VERSION}
|
|
|
{$ifdef VER1_0}
|
|
|
LANG_ARABIC = $01;
|
|
@@ -469,6 +470,7 @@ const
|
|
|
// reverse convert routines
|
|
|
//*************************************************************************//
|
|
|
|
|
|
+// Visual DBaseVII specific; the IsFoxPro means a FoxPro codepage, which DB7 supports
|
|
|
function ConstructLangName(CodePage: Integer; Locale: LCID; IsFoxPro: Boolean): string;
|
|
|
|
|
|
function ConstructLangId(CodePage: Integer; Locale: LCID; IsFoxPro: Boolean): Byte;
|
|
@@ -521,7 +523,7 @@ begin
|
|
|
end;
|
|
|
|
|
|
const
|
|
|
- // range of Dbase locales; these are INCLUSIVE (the rest are FoxPro?)
|
|
|
+ // range of Dbase locales; these are INCLUSIVE (the rest are FoxPro)
|
|
|
dBase_RegionCount = 4;
|
|
|
dBase_Regions: array[0..dBase_RegionCount*2-1] of Byte =
|
|
|
($00, $00,
|
|
@@ -529,9 +531,8 @@ const
|
|
|
$69, $69, // a lonely dbf entry :-)
|
|
|
$80, $90);
|
|
|
|
|
|
-function FindLangId(CodePage, Info2: Cardinal; Info2Table: PCardinal; IsFoxPro: Boolean): Byte;
|
|
|
-// Info2: desired locale
|
|
|
-// Info2Table: pointer to lookup array: language ID=>locale cardinal
|
|
|
+function FindLangId(CodePage, DesiredLocale: Cardinal; LanguageIDToLocaleTable: PCardinal; IsFoxPro: Boolean): Byte;
|
|
|
+// DesiredLocale: pointer to lookup array: language ID=>locale
|
|
|
var
|
|
|
LangID, Region, FoxRes, DbfRes: Integer;
|
|
|
begin
|
|
@@ -549,7 +550,7 @@ begin
|
|
|
// what a mess :-(
|
|
|
//todo: verify this for visual foxpro; we never seem to get a result
|
|
|
if ((LangId_To_CodePage[LangID] = CodePage) or (CodePage = 0)) and
|
|
|
- (PCardinal(PChar(Info2Table)+(LangID*4))^ = Info2) then
|
|
|
+ (PCardinal(PChar(LanguageIDToLocaleTable)+(LangID*4))^ = DesiredLocale) then
|
|
|
if LangID <= dBase_Regions[Region+1] then
|
|
|
DbfRes := Byte(LangID)
|
|
|
else
|
|
@@ -557,7 +558,7 @@ begin
|
|
|
end;
|
|
|
// if we can find langid in other set, use it
|
|
|
if (DbfRes <> 0) and (not IsFoxPro or (FoxRes = 0)) then
|
|
|
- Result := DbfRes //if not using foxpro
|
|
|
+ Result := DbfRes //... not using foxpro
|
|
|
else {(DbfRes = 0) or (IsFoxPro and (FoxRes <> 0)}
|
|
|
if (FoxRes <> 0) {and (IsFoxPro or (DbfRes = 0)} then
|
|
|
Result := FoxRes
|
|
@@ -565,45 +566,6 @@ begin
|
|
|
Result := 0;
|
|
|
end;
|
|
|
|
|
|
-{
|
|
|
-function FindLangId(CodePage, Info2: Cardinal; Info2Table: PCardinal; IsFoxPro: Boolean): Byte;
|
|
|
-var
|
|
|
- I, Region, lEnd: Integer;
|
|
|
- EndReached: Boolean;
|
|
|
-begin
|
|
|
- Region := 0;
|
|
|
- Result := 0;
|
|
|
- repeat
|
|
|
- // determine region to scan
|
|
|
- if IsFoxPro then
|
|
|
- begin
|
|
|
- // foxpro, in between dbase regions
|
|
|
- I := dBase_Regions[Region+1] + 1;
|
|
|
- lEnd := dBase_Regions[Region+2] - 1;
|
|
|
- EndReached := Region = dBase_RegionCount*2-4;
|
|
|
- end else begin
|
|
|
- // dBase, select regions
|
|
|
- I := dBase_Regions[Region];
|
|
|
- lEnd := dBase_Regions[Region+1];
|
|
|
- EndReached := Region = dBase_RegionCount*2-2;
|
|
|
- end;
|
|
|
- // scan
|
|
|
- repeat
|
|
|
- // it seems delphi does not properly understand pointers?
|
|
|
- // what a mess :-(
|
|
|
- if (LangId_To_CodePage[I] = CodePage) and (PCardinal(PChar(Info2Table)+(I*4))^ = Info2) then
|
|
|
- Result := Byte(I);
|
|
|
- Inc(I);
|
|
|
- // lEnd is included in range
|
|
|
- until (Result <> 0) or (I > lEnd);
|
|
|
- // goto next region
|
|
|
- if (Result = 0) then
|
|
|
- Inc(Region, 2);
|
|
|
- // found or end?
|
|
|
- until (Result <> 0) or EndReached;
|
|
|
-end;
|
|
|
-}
|
|
|
-
|
|
|
function ConstructLangId(CodePage: Integer; Locale: LCID; IsFoxPro: Boolean): Byte;
|
|
|
begin
|
|
|
// locale: lower 16bits only, with default sorting
|
|
@@ -639,6 +601,12 @@ begin
|
|
|
else
|
|
|
CodePage := StrToInt(CodePageStr);
|
|
|
// find lang id
|
|
|
+ //todo: debug, remove
|
|
|
+ writeln('');
|
|
|
+ writeln('getlangid_fromLangName');
|
|
|
+ writeln('codepagestr ',codepagestr);
|
|
|
+ writeln('subtype: ',subtype);
|
|
|
+ writeln('codepage: ',codepage);
|
|
|
Result := FindLangId(CodePage, SubType, @LangId_To_LocaleStr[0], IsFoxPro);
|
|
|
end;
|
|
|
|