public CharsetUTF7(String icuCanonicalName, String javaCanonicalName, String[] aliases) {
super(icuCanonicalName, javaCanonicalName, aliases);
- maxBytesPerChar=4; /* max 3 bytes per code unit from UTF-7 (base64) */
+ maxBytesPerChar=5; /* max 3 bytes per code unit from UTF-7 (base64) plus SIN SOUT */
minBytesPerChar=1;
maxCharsPerByte=1;
import java.nio.charset.UnsupportedCharsetException;
import java.nio.charset.spi.CharsetProvider;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Iterator;
import java.util.MissingResourceException;
import java.util.Set;
//end of charset encoder code coverage code
}
+ @Test
+ public void TestBug12956() {
+ final CharsetProvider provider = new CharsetProviderICU();
+ final Charset cs_utf7 = provider.charsetForName("UTF-7");
+ final Charset cs_imap = provider.charsetForName("IMAP-mailbox-name");
+ final String test = "新";
+ final byte[] expected_utf7 = {0x2b, 0x5a, 0x62, 0x41, 0x2d};
+ final byte[] expected_imap = {0x26, 0x5a, 0x62, 0x41, 0x2d};
+
+ byte[] bytes = test.getBytes(cs_utf7);
+ if (!Arrays.equals(bytes, expected_utf7)) {
+ errln("Incorrect UTF-7 conversion. Got " + new String(bytes) + " but expect " +
+ new String(expected_utf7));
+ }
+
+ bytes = test.getBytes(cs_imap);
+ if (!Arrays.equals(bytes, expected_imap)) {
+ errln("Incorrect IMAP-mailbox-name conversion. Got " + new String(bytes) +
+ " but expect " + new String(expected_imap));
+ }
+ }
+
//Test Charset ISCII
@Test
public void TestCharsetISCII() {