Revision 33204 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/dbf/DbaseFile.java
DbaseFile.java | ||
---|---|---|
22 | 22 |
import java.util.Calendar; |
23 | 23 |
import java.util.Date; |
24 | 24 |
import java.util.Locale; |
25 |
import java.util.prefs.Preferences; |
|
25 | 26 |
|
26 | 27 |
import javax.swing.JOptionPane; |
27 | 28 |
|
... | ... | |
398 | 399 |
// create the header to contain the header information. |
399 | 400 |
myHeader = new DbaseFileHeader(); |
400 | 401 |
myHeader.readHeader(buffer); |
401 |
String charSetName = DbfEncodings.getInstance().getCharsetForDbfId(myHeader.getLanguageID()); |
|
402 |
if ((charSetName != null && !charSetName.equalsIgnoreCase("UNKNOWN"))){ |
|
403 |
try{ |
|
404 |
charSet = Charset.forName(charSetName); |
|
405 |
}catch (UnsupportedCharsetException e) { |
|
406 |
charSet = Charset.defaultCharset(); |
|
402 |
if (charSet == null) { |
|
403 |
// Firsttime: |
|
404 |
Preferences prefs = Preferences.userRoot().node( "gvSIG.encoding.dbf" ); |
|
405 |
String defaultCharSetName=prefs.get("dbf_encoding", DbaseFile.getDefaultCharset().toString()); |
|
406 |
String charSetName = DbfEncodings.getInstance().getCharsetForDbfId(myHeader.getLanguageID()); |
|
407 |
// If the file has a charset already set, use it. If not, use the one from preferences |
|
408 |
if ((charSetName == null) || (charSetName.equalsIgnoreCase("UNKNOWN"))){ |
|
409 |
try { |
|
410 |
charSet = Charset.forName(defaultCharSetName); |
|
411 |
} |
|
412 |
catch (UnsupportedCharsetException e) { |
|
413 |
charSet = Charset.defaultCharset(); |
|
414 |
} |
|
407 | 415 |
} |
416 |
else { // Use the charset set to the file |
|
417 |
try{ |
|
418 |
charSet = Charset.forName(charSetName); |
|
419 |
}catch (UnsupportedCharsetException e) { |
|
420 |
charSet = Charset.defaultCharset(); |
|
421 |
} |
|
422 |
} |
|
423 |
// if (charSet==null){ |
|
424 |
// charSet = Charset.defaultCharset(); |
|
425 |
// } |
|
426 |
|
|
427 |
|
|
408 | 428 |
} |
409 |
if (charSet==null){ |
|
410 |
charSet = Charset.defaultCharset(); |
|
411 |
} |
|
412 | 429 |
bytesCachedRecord = new byte[myHeader.getRecordLength()]; |
413 | 430 |
}catch (IOException e) { |
414 | 431 |
throw new FileNotFoundDriverException("DBF",e,file.getAbsolutePath()); |
Also available in: Unified diff