Class DbaseCodepage
java.lang.Object
org.gvsig.fmap.dal.store.dbf.utils.DbaseCodepage
Reads and writes codepage (.cpg) files which are sometime
used to externally specify the charset encoding of a DBF file.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final short[]Define the valid dbf Language driver IDs (equivalent to MSDOS code pages), which are used on the byte 29 of the DBF header to define the DBF codepage.static final String[]Equivalent Java charset names to the code pages defined indbfLdid, using Java NIO Charset names (which differ from JAVA IO names, see https://docs.oracle.com/javase/8/docs/technotes/guides/intl/encoding.doc.html) -
Constructor Summary
ConstructorsConstructorDescriptionDbaseCodepage(File dbfFile) Defines the dbfFile and constructs the name of the .cpg file based on it -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringstatic StringgetCharsetName(int ldid) Gets the Java NIO charset name equivalent to the provided ldid value.static StringgetCpgFileName(String dbfFile) static intGets the dbf Language driver IDs (code pages) corresponding to the provided charset namestatic Stringread()Reads the charset from the codepage file, and updates the internal charset definitionvoidsetCharset(String charset) voidWrites the specified charset to the codepage file, and updates the internal charset definition
-
Field Details
-
dbfLdid
public static final short[] dbfLdidDefine the valid dbf Language driver IDs (equivalent to MSDOS code pages), which are used on the byte 29 of the DBF header to define the DBF codepage. The equivalences of these charsets using Java NIO charset names are defined on theldidJavaarray (so 0x01 is equivalent to IBM437, 0x02 to IBM850, etc) See some other equivalences in: https://github.com/infused/dbf/blob/master/docs/supported_encodings.csv https://github.com/olemb/dbfread/blob/master/dbfread/codepages.py https://joinup.ec.europa.eu/svn/gvsig-desktop/trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/dbf/DbfEncodings.java -
ldidJava
Equivalent Java charset names to the code pages defined indbfLdid, using Java NIO Charset names (which differ from JAVA IO names, see https://docs.oracle.com/javase/8/docs/technotes/guides/intl/encoding.doc.html)
-
-
Constructor Details
-
DbaseCodepage
Defines the dbfFile and constructs the name of the .cpg file based on it
-
-
Method Details
-
getCpgFileName
-
getCharset
-
setCharset
-
cpg2java
-
java2cpg
-
read
Reads the charset from the codepage file, and updates the internal charset definition -
write
Writes the specified charset to the codepage file, and updates the internal charset definition -
getLdid
Gets the dbf Language driver IDs (code pages) corresponding to the provided charset name- Returns:
- The LDID code, or 0x00 if no equivalent LDID code was found for the provided charsetName
-
getCharsetName
Gets the Java NIO charset name equivalent to the provided ldid value. Gets null if the provided ldid is not recognised as a valid code
-