I have a dbf file encoded as 866 (DOS) codepage
Using the code below, I am trying to read it. The problem is that the lines that I get are formed as if the file was on code page 1252. I have not yet checked other issues in SO and other forums. Looking for hot ideas to read this.
var ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\PathtoFile\;Extended Properties=""dBase 5.0"""; var dBaseConnection = new System.Data.OleDb.OleDbConnection(ConnectionString ); dBaseConnection.Open(); var dBaseCommand = new System.Data.OleDb.OleDbCommand("SELECT * FROM FileName",dBaseConnection); var dBaseDataReader = dBaseCommand.ExecuteReader(CommandBehavior.SequentialAccess); while( dBaseDataReader.Read()){ Encoding.GetEncoding(866).GetString(Encoding.GetEncoding(1252).GetBytes(dBaseDataReader.GetString(2)).Dump(); // Does not help }
Where is the file located? What other file extensions are in the same folder (for example, FPT / CDX / IDX / NTX)? This should give us an idea of ββwhether it is VFP or dBase or Clipper or something else.
If this is Visual Foxpro (VFP) data, then you must install the VFPOLEDB provider from http://www.microsoft.com/en-gb/download/details.aspx?id=14839 and use one of the following connection strings from http: / /www.connectionstrings.com/visual-foxpro#vfp-ole-db-provider .
Database Container (.DBC):
Provider=vfpoledb;Data Source=C:\MyDbFolder\MyDbContainer.dbc;Collating Sequence=machine;
Free table directory:
Provider=vfpoledb;Data Source=C:\MyDataDirectory\;Collating Sequence=general;
Connect to one DBF file:
Provider=vfpoledb;Data Source=C:\MyDataDirectory\MyTable.dbf;Collating Sequence=machine;
Additional information on the VFPOLEDB provider at http://msdn.microsoft.com/en-us/library/aa975609%28v=vs.71%29.aspx
Of interest, as you know, is it encoded as codepage 866? Byte at offset 29 in DBF Visual Foxpro stores the code page label. See http://msdn.microsoft.com/en-us/library/aa975386%28v=vs.71%29.aspx
I do not see evidence that you received 1252 encoded data. Your code trying to covnert from 1252 to 866 code pages failed. Thus, it is not encoded in 1252. I have currently fixed a problem in which the driver returned a string of more than one byte. Perhaps this is your problem.
Decision:
Check the key value HKLM \ SOFTWARE \ Microsoft \ Jet \ 4.0 \ Engines \ Xbase \ BDE. It should be 2. If not or the key does not exist (this was my case), create a DWORD parameter and set it to 2.
More information about this key can be found here: http://support.microsoft.com/kb/307455/en-us
Source: https://habr.com/ru/post/1441490/More articles:How to make simple traffic control for a specific port using the "tc" command - linuxComparative and comparative interface in Java - javahow to set a logger when calling ant target from java - javaIndeed, the basic example of moq does not work - c #https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1441489/converting-class-properties-to-key-value-pair&usg=ALkJrhipqO3rioLLJ1Bjst91i5rrpjz6-AWhat is the difference between Java API and Java methods - javaMapping elements with multiple rows from mysql to solr - mysqlDjango form field cleared to check if the entered date is in the saved range - djangoC # naming conventions in namespaces - c #Access to records in csv files for calculating F # - arraysAll Articles