diff -Nur poi.original/src/java/org/apache/poi/hssf/model/Workbook.java poi.patched/src/java/org/apache/poi/hssf/model/Workbook.java --- poi.original/src/java/org/apache/poi/hssf/model/Workbook.java 2004-07-28 20:06:32.000000000 +0700 +++ poi.patched/src/java/org/apache/poi/hssf/model/Workbook.java 2005-03-16 17:42:06.264563855 +0600 @@ -29,6 +29,7 @@ import java.util.Iterator; import java.util.List; import java.util.Locale; +import java.io.UnsupportedEncodingException; /** * Low level model implementation of a Workbook. Provides creational methods @@ -1963,6 +1964,7 @@ maxformatid = maxformatid >= (short) 0xa4 ? (short) ( maxformatid + 1 ) : (short) 0xa4; //Starting value from M$ empiracle study. rec.setIndexCode( maxformatid ); rec.setFormatStringLength( (byte) format.length() ); + rec.setUnicodeFlag(isUnicodeFormat(format)); rec.setFormatString( format ); int pos = 0; @@ -1974,6 +1976,17 @@ return maxformatid; } + /** + * @param format + * @return true if format is Unicode. + */ + private boolean isUnicodeFormat(final String format) { + try { + return !format.equals(new String(format.getBytes("ISO-8859-1"), "ISO-8859-1")); + } catch (UnsupportedEncodingException e) { + return true; + } + } /** * Returns the first occurance of a record matching a particular sid.