@@ -0,0 +1,1505 @@
+package org.bouncycastle.openpgp.test;%0A%0Aimport org.bouncycastle.bcpg.ArmoredOutputStream;%0Aimport org.bouncycastle.util.test.SimpleTest;%0A%0Aimport java.io.ByteArrayOutputStream;%0Aimport java.nio.charset.Charset;%0A%0Apublic class ArmoredOutputStreamUTF8Test extends SimpleTest %7B%0A%0A    private static final Charset utf8 = Charset.forName(%22UTF8%22);%0A%0A    public static void main(String%5B%5D args) %7B%0A        runTest(new ArmoredOutputStreamUTF8Test());%0A    %7D%0A%0A    @Override%0A    public String getName() %7B%0A        return ArmoredOutputStreamUTF8Test.class.getSimpleName();%0A    %7D%0A%0A    @Override%0A    public void performTest() throws Exception %7B%0A        String utf8WithUmlauts = %22%C3%84%C3%96%C3%9C%C3%9F&Umlauts%22;%0A%0A        ByteArrayOutputStream out = new ByteArrayOutputStream();%0A        ArmoredOutputStream armorOut = new ArmoredOutputStream(out);%0A        armorOut.setHeader(%22Comment%22, utf8WithUmlauts);%0A%0A        armorOut.write(%22Foo%5CnBar%22.getBytes(utf8));%0A%0A        armorOut.close();%0A%0A        String armoredOutput = out.toString();%0A        String%5B%5D lines = armoredOutput.split(%22%5Cn%22);%0A        String comment = null;%0A        for (String line : lines) %7B%0A            if (line.startsWith(%22Comment: %22)) %7B%0A                comment = line.substring(%22Comment: %22.length());%0A                break;%0A            %7D%0A        %7D%0A%0A        isTrue(%22We did not find the comment line. This MUST never happen.%22, comment != null);%0A        isEquals(%22Comment was not properly encoded. Expected: %22  +utf8WithUmlauts + %22, Actual: %22 + comment, comment, utf8WithUmlauts);%0A    %7D%0A%7D%0A

Add test for UTF8 encoding issues in ASCII armor