From: Simon Steiner Date: Fri, 5 Jun 2015 14:23:11 +0000 (+0000) Subject: FOP-2474: AFP Logical element tag incorrect character encoding X-Git-Tag: fop-2_1~63 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=96d24577ac02b5cba48a973cfe5b568ffa7ff4a2;p=xmlgraphics-fop.git FOP-2474: AFP Logical element tag incorrect character encoding git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1683762 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/afp/modca/TagLogicalElement.java b/src/java/org/apache/fop/afp/modca/TagLogicalElement.java index dbd402335..ea30154d5 100644 --- a/src/java/org/apache/fop/afp/modca/TagLogicalElement.java +++ b/src/java/org/apache/fop/afp/modca/TagLogicalElement.java @@ -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) { diff --git a/src/java/org/apache/fop/afp/modca/triplets/AttributeValueTriplet.java b/src/java/org/apache/fop/afp/modca/triplets/AttributeValueTriplet.java index 1c10a1ed0..2ba34d40e 100644 --- a/src/java/org/apache/fop/afp/modca/triplets/AttributeValueTriplet.java +++ b/src/java/org/apache/fop/afp/modca/triplets/AttributeValueTriplet.java @@ -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"); }