]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
FOP-2474: AFP Logical element tag incorrect character encoding
authorSimon Steiner <ssteiner@apache.org>
Fri, 5 Jun 2015 14:23:11 +0000 (14:23 +0000)
committerSimon Steiner <ssteiner@apache.org>
Fri, 5 Jun 2015 14:23:11 +0000 (14:23 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1683762 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/afp/modca/TagLogicalElement.java
src/java/org/apache/fop/afp/modca/triplets/AttributeValueTriplet.java

index dbd40233505e2a530a12f0a85c11755c49ec8a90..ea30154d5b9046a0de8dee29cfe6b9ea3393fe78 100644 (file)
@@ -64,7 +64,11 @@ public class TagLogicalElement extends AbstractTripletStructuredObject {
     }
 
     private void setAttributeValue(String value) {
-        addTriplet(new AttributeValueTriplet(value));
+        if (state.encoding != -1) {
+            addTriplet(new AttributeValueTriplet(value, state.encoding));
+        }  else {
+            addTriplet(new AttributeValueTriplet(value));
+        }
     }
 
     private void setEncoding(int encoding) {
index 1c10a1ed03eee2b1f8d0074d7584e94c7d63736e..2ba34d40e42407d6d1372ca16e0396665e9a6d08 100644 (file)
@@ -32,6 +32,8 @@ import org.apache.fop.afp.AFPConstants;
 public class AttributeValueTriplet extends AbstractTriplet {
     private String attVal;
 
+    private int userEncoding = -1; //no encoding by default
+
     /**
      * Main constructor
      *
@@ -42,6 +44,11 @@ public class AttributeValueTriplet extends AbstractTriplet {
         this.attVal = truncate(attVal, MAX_LENGTH - 4);
     }
 
+    public AttributeValueTriplet(String attVal, int userEncoding) {
+        this(attVal);
+        this.userEncoding = userEncoding;
+    }
+
     /** {@inheritDoc} */
     public void writeToStream(OutputStream os) throws IOException {
         byte[] data = super.getData();
@@ -51,7 +58,11 @@ public class AttributeValueTriplet extends AbstractTriplet {
         // convert name and value to ebcdic
         byte[] tleByteValue = null;
         try {
-            tleByteValue = attVal.getBytes(AFPConstants.EBCIDIC_ENCODING);
+            if (this.userEncoding != -1) {
+                tleByteValue = attVal.getBytes("Cp" + userEncoding);
+            } else {
+                tleByteValue = attVal.getBytes(AFPConstants.EBCIDIC_ENCODING);
+            }
         } catch (UnsupportedEncodingException usee) {
             throw new IllegalArgumentException(attVal + " encoding failed");
         }