Revision 40422 branches/v2_0_0_prep/libraries/libFMap_dalfile/src/org/gvsig/fmap/dal/store/dbf/utils/DbaseFileHeader.java
DbaseFileHeader.java | ||
---|---|---|
11 | 11 |
import java.nio.ByteBuffer; |
12 | 12 |
import java.nio.ByteOrder; |
13 | 13 |
import java.nio.channels.FileChannel; |
14 |
import java.nio.charset.Charset; |
|
15 |
import java.util.ArrayList; |
|
14 | 16 |
import java.util.Calendar; |
15 | 17 |
import java.util.Date; |
16 | 18 |
import java.util.Iterator; |
19 |
import java.util.List; |
|
20 |
import java.util.Set; |
|
21 |
import java.util.SortedMap; |
|
17 | 22 |
|
18 | 23 |
import org.gvsig.fmap.dal.DataTypes; |
19 | 24 |
import org.gvsig.fmap.dal.exception.UnsupportedVersionException; |
... | ... | |
64 | 69 |
private DbaseFieldDescriptor[] myFieldDescriptions; |
65 | 70 |
|
66 | 71 |
private byte myLanguageID; |
72 |
|
|
73 |
private List<String> encodingSupportedByString = null; |
|
67 | 74 |
|
68 | 75 |
/** |
69 | 76 |
* DbaseFileHreader constructor comment. |
70 | 77 |
*/ |
71 | 78 |
public DbaseFileHeader() { |
72 | 79 |
super(); |
80 |
|
|
81 |
encodingSupportedByString = new ArrayList<String>(); |
|
82 |
SortedMap<String, Charset> m = Charset.availableCharsets(); |
|
83 |
Set<String> k = m.keySet(); |
|
84 |
Iterator<String> it = k.iterator(); |
|
85 |
while(it.hasNext()) { |
|
86 |
encodingSupportedByString.add(it.next()); |
|
87 |
} |
|
73 | 88 |
} |
74 | 89 |
|
75 | 90 |
/** |
... | ... | |
412 | 427 |
myLanguageID = in.get(); |
413 | 428 |
if (charsName == null) { |
414 | 429 |
charsName = getCharsetName(); |
430 |
charsName = mappingEncoding(charsName); |
|
415 | 431 |
} |
416 | 432 |
|
417 | 433 |
|
... | ... | |
694 | 710 |
} |
695 | 711 |
} |
696 | 712 |
|
713 |
/** |
|
714 |
* 01h DOS USA code page 437 |
|
715 |
02h DOS Multilingual code page 850 |
|
716 |
03h Windows ANSI code page 1252 |
|
717 |
04h Standard Macintosh |
|
718 |
64h EE MS-DOS code page 852 |
|
719 |
65h Nordic MS-DOS code page 865 |
|
720 |
66h Russian MS-DOS code page 866 |
|
721 |
67h Icelandic MS-DOS |
|
722 |
68h Kamenicky (Czech) MS-DOS |
|
723 |
69h Mazovia (Polish) MS-DOS |
|
724 |
6Ah Greek MS-DOS (437G) |
|
725 |
6Bh Turkish MS-DOS |
|
726 |
96h Russian Macintosh |
|
727 |
97h Eastern European Macintosh |
|
728 |
98h Greek Macintosh |
|
729 |
C8h Windows EE code page 1250 |
|
730 |
C9h Russian Windows |
|
731 |
CAh Turkish Windows |
|
732 |
CBh Greek Windows |
|
733 |
* @return |
|
734 |
*/ |
|
697 | 735 |
public String getCharsetName() { |
698 | 736 |
switch (getLanguageID()) { |
699 | 737 |
case 0x01: |
... | ... | |
725 | 763 |
return "ISO-8859-1"; |
726 | 764 |
} |
727 | 765 |
} |
766 |
|
|
767 |
public String mappingEncoding(String dbfEnconding) { |
|
768 |
if(encodingSupportedByString.contains(dbfEnconding)) |
|
769 |
return dbfEnconding; |
|
770 |
else |
|
771 |
return "UTF-8"; |
|
772 |
} |
|
728 | 773 |
|
729 | 774 |
} |
Also available in: Unified diff