ICU-9205 Update max bytes per char calculation for EBCDIC DBCS types

X-SVN-Rev: 31675
This commit is contained in:
Michael Ow 2012-04-03 22:18:45 +00:00
parent 59a449036f
commit 230db005ae
2 changed files with 23 additions and 4 deletions

View file

@ -1,6 +1,6 @@
/**
*******************************************************************************
* Copyright (C) 2006-2011, International Business Machines Corporation and *
* Copyright (C) 2006-2012, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*
@ -913,7 +913,8 @@ class CharsetMBCS extends CharsetICU {
/* fix maxBytesPerUChar depending on outputType and options etc. */
if (outputType == MBCS_OUTPUT_2_SISO) {
maxBytesPerChar = 3; /* SO+DBCS */
/* changed from 3 to 4 in ICU4J only. #9205 */
maxBytesPerChar = 4; /* SO+DBCS+SI*/
}
extIndexes = mbcsTable.extIndexes;

View file

@ -1,6 +1,6 @@
/**
*******************************************************************************
* Copyright (C) 2006-2011, International Business Machines Corporation and *
* Copyright (C) 2006-2012, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*
@ -5656,7 +5656,7 @@ public class TestCharset extends TestFmwk {
int[] expected = {
40,
20,
60,
80, /* changed from 60 to 80 to reflect the updates by #9205 */
80,
60
};
@ -5717,4 +5717,22 @@ public class TestCharset extends TestFmwk {
}
}
}
/*
* When converting with the String method getBytes(), buffer overflow exception is thrown because
* of the way ICU4J is calculating the max bytes per char. This should be changed only on the ICU4J
* side to match what the Java method is expecting. The ICU4C size will be left unchanged.
* Ticket #9205
*/
public void TestBufferOverflowErrorUsingJavagetBytes() {
String charsetName = "ibm-5035";
String testCase = "\u7d42";
try {
testCase.getBytes(charsetName);
} catch (Exception ex) {
errln("Error calling getBytes(): " + ex);
}
}
}