Alaska Software Inc. - Re: Dbf Data Conversion - Finished
Username: Password:
AuthorTopic: Re: Dbf Data Conversion - Finished
Andreas Gehrs-Pahl

View the complete thread for this message in:

Re: Dbf Data Conversion - Finished
on Sat, 10 Dec 2016 18:03:46 -0500
Carlos,

>The Xbase++ docs are not clear about DbInfo() and DbeInfo().
>Making many tests I discovered that DbInfo(DBFDBO_ANSI) returns the Code 
>Page existing in the header of the Dbf.

As I explained several times before, this is incorrect. DbInfo(DBFDBO_ANSI) 
doesn't return the Code Page, as the DBFDBE doesn't know anything about code 
pages!

DbInfo(DBFDBO_ANSI) can only be used for database files that were opened 
with the DBFDBE. It should never be used with any other DBE, as the results 
are not defined and could be virtually anything, including runtime errors.

DbInfo(DBFDBO_ANSI) returns either 0 or 1, depending on what was previously 
set for the database table with DbeInfo(COMPONENT_DATA, DBFDBE_ANSI). The 
default value is 0, meaning that the table is treated as containing OEM 
data. If you use DbeInfo(COMPONENT_DATA, DBFDBE_ANSI, .t.) before opening a 
database table with the DBFDBE, DbInfo(DBFDBO_ANSI) will return 1, instead.
In that case, the DBFDBE will treat that file as if it contains ANSI data, 
and it will disable any implicit character set conversions, if the thread's 
current CharSet setting is also set to ANSI, or convert data between OEM and 
ANSI, when the thread's current CharSet setting is OEM.

If you instead open a database with the FOXDBE, and the database is a VFP 
database, you can use DbInfo(FOXDBO_CODEPAGE) to determine the Code Page 
value that is saved in the VFP database header. The return value for any 
non-VFP database will always be 0, as no code page can be specified in the 
header of non-VFP databases.

The fact that both constants -- coincidentally -- have the same value, 1007, 
doesn't mean that they do the same thing or that you can exchange them.

Your code should determine which DBE is actually in use, as I showed you in 
my post from 11/29/2016:

if left((cAlias)->(DbInfo(DBO_DBENAME)), 3) == "FOX"
   nCodepage := (cAlias)->(DbInfo(FOXDBO_CODEPAGE))
else
   nCodepage := 0	 actually undefined or OEM (aka Code Page 437)
endif

At least change the constant from DBFDBO_ANSI to FOXDBO_CODEPAGE in your 
code, as Alaska could change the value of those #define constants at any 
time, and then your code wouldn't work anymore, even for the FOXDBE, which 
you are apparently always using anyway.

Andreas

Andreas Gehrs-Pahl
Absolute Software, LLC

phone: (989) 723-9927
email: Andreas@AbsoluteSoftwareLLC.com
web:   http://www.AbsoluteSoftwareLLC.com
[F]:   https://www.facebook.com/AbsoluteSoftwareLLC