Browse Source

fcl-db/dbase: further improvement on r24253 though no solution yet.

git-svn-id: trunk@24254 -
reiniero 12 years ago
parent
commit
996b26b936

+ 6 - 14
packages/fcl-db/src/dbase/dbf_dbffile.pas

@@ -195,7 +195,6 @@ type
     destructor Destroy; override;
     destructor Destroy; override;
 
 
     function CodePageInstalled(ACodePage: Integer): Boolean;
     function CodePageInstalled(ACodePage: Integer): Boolean;
-    function CreateFoxProLangID(NewCodePage: integer): Byte;
 
 
     property CurrencyAsBCD: Boolean read FCurrencyAsBCD write FCurrencyAsBCD;
     property CurrencyAsBCD: Boolean read FCurrencyAsBCD write FCurrencyAsBCD;
     property DefaultOpenCodePage: Integer read FDefaultOpenCodePage write FDefaultOpenCodePage;
     property DefaultOpenCodePage: Integer read FDefaultOpenCodePage write FDefaultOpenCodePage;
@@ -630,21 +629,19 @@ begin
     // determine codepage & locale
     // determine codepage & locale
     if FDbfVersion in [xFoxPro, xVisualFoxPro] then
     if FDbfVersion in [xFoxPro, xVisualFoxPro] then
     begin
     begin
-      if FFileLangId = 0 then
-        FFileLangId := DbfGlobals.CreateFoxProLangID(DbfGlobals.DefaultCreateCodePage);
-      FFileCodePage := LangId_To_CodePage[FFileLangId];
-      lLocaleID := LangId_To_Locale[FFileLangId];
-      FUseCodePage := FFileCodePage;
+      // Don't use DbfGlobals default language ID as it is dbase-based
+      FFileLangId := ConstructLangId(LangId_To_CodePage[FFileLangId],GetUserDefaultLCID, true);
     end
     end
     else
     else
     begin
     begin
       // DBase
       // DBase
       if FFileLangId = 0 then
       if FFileLangId = 0 then
         FFileLangId := DbfGlobals.DefaultCreateLangId;
         FFileLangId := DbfGlobals.DefaultCreateLangId;
-      FFileCodePage := LangId_To_CodePage[FFileLangId];
-      lLocaleID := LangId_To_Locale[FFileLangId];
-      FUseCodePage := FFileCodePage;
     end;
     end;
+    FFileCodePage := LangId_To_CodePage[FFileLangId];
+    lLocaleID := LangId_To_Locale[FFileLangId];
+    FUseCodePage := FFileCodePage;
+
 
 
     // prepare header size
     // prepare header size
     if FDbfVersion = xBaseVII then
     if FDbfVersion = xBaseVII then
@@ -3088,11 +3085,6 @@ begin
   Result := FCodePages.IndexOf(Pointer(ACodePage)) >= 0;
   Result := FCodePages.IndexOf(Pointer(ACodePage)) >= 0;
 end;
 end;
 
 
-function TDbfGlobals.CreateFoxProLangID(NewCodePage: integer): Byte;
-begin
-  ConstructLangId(NewCodePage, GetUserDefaultLCID, true);
-end;
-
 initialization
 initialization
 finalization
 finalization
   FreeAndNil(DbfGlobals);
   FreeAndNil(DbfGlobals);

+ 2 - 2
packages/fcl-db/src/dbase/dbf_lang.pas

@@ -521,8 +521,7 @@ begin
 end;
 end;
 
 
 const
 const
-  // range of Dbase / FoxPro locale; these are INCLUSIVE
-
+  // range of Dbase / FoxPro locales; these are INCLUSIVE
   dBase_RegionCount = 4;
   dBase_RegionCount = 4;
   dBase_Regions: array[0..dBase_RegionCount*2-1] of Byte =
   dBase_Regions: array[0..dBase_RegionCount*2-1] of Byte =
    ($00, $00,
    ($00, $00,
@@ -538,6 +537,7 @@ begin
   DbfRes := 0;
   DbfRes := 0;
   FoxRes := 0;
   FoxRes := 0;
   // scan
   // scan
+  //todo: verify this for visual foxpro; it doesn't seem to work.
   for I := 0 to $FF do
   for I := 0 to $FF do
   begin
   begin
     // check if need to advance to next region
     // check if need to advance to next region