You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I'm using this library to change the column size/type of some DBF created with GEOTOOL package.
The original version of the DBF files works fine, but when I create a new DBF from the scratch, add the headers and the fields read from the original file (that are in ISO-8859-1), no matter what i do, the final files have a different (windows-1252) charset.
As you can see in the following snippet, I'm passing the charset to the reader and to the writer and, if i print out the charset with the proper method, it seems properly set (ISO-8859-1), but If i open the shape file in QGIS, it says that it has the "windows-1252" charset.
`
DBFReader reader = null;
DBFField[] fields = null;
File originalDBF = new File("original_file.dbf");
File newDBF = new File("final_file.dbf");
try {
FileInputStream fis = new FileInputStream(originalDBF);
FileOutputStream fos = new FileOutputStream(newDBF);
reader = new DBFReader(fis,Charset.forName("ISO-8859-1"));
DBFWriter writer = new DBFWriter(fos, Charset.forName("ISO-8859-1"));
int numberOfFields = reader.getFieldCount();
fields = new DBFField[numberOfFields];
for (int i = 0; i < numberOfFields; i++) {
DBFField originalField = reader.getField(i);
fields[i] = new DBFField();
fields[i].setName(originalField.getName());
fields[i].setType(originalField.getType());
//DOING SOMETHING WITH THE FIELDS HEADER
}
writer.setFields(fields);
Object[] rowObjects;
Object rowData[] = new Object[numberOfFields];
while ((rowObjects = reader.nextRecord()) != null) {
for (int i = 0; i < rowObjects.length; i++) {
//DOING SOMETHING WITH THE ROWS
}
writer.addRecord(rowData);
}
writer.close();
} catch (DBFException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
DBFUtils.close(reader);
}
`
Could you please help me?
The text was updated successfully, but these errors were encountered:
Hi,
I'm using this library to change the column size/type of some DBF created with GEOTOOL package.
The original version of the DBF files works fine, but when I create a new DBF from the scratch, add the headers and the fields read from the original file (that are in ISO-8859-1), no matter what i do, the final files have a different (windows-1252) charset.
As you can see in the following snippet, I'm passing the charset to the reader and to the writer and, if i print out the charset with the proper method, it seems properly set (ISO-8859-1), but If i open the shape file in QGIS, it says that it has the "windows-1252" charset.
`
`
Could you please help me?
The text was updated successfully, but these errors were encountered: