diff options
author | Simon Steiner <ssteiner@apache.org> | 2015-06-05 14:23:11 +0000 |
---|---|---|
committer | Simon Steiner <ssteiner@apache.org> | 2015-06-05 14:23:11 +0000 |
commit | 96d24577ac02b5cba48a973cfe5b568ffa7ff4a2 (patch) | |
tree | c48f81bfd3ada3758431d72a78541e070b05adaf /src/java/org | |
parent | 399d10251b199159a1c109902b1eefec5f0fd976 (diff) | |
download | xmlgraphics-fop-96d24577ac02b5cba48a973cfe5b568ffa7ff4a2.tar.gz xmlgraphics-fop-96d24577ac02b5cba48a973cfe5b568ffa7ff4a2.zip |
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
Diffstat (limited to 'src/java/org')
-rw-r--r-- | src/java/org/apache/fop/afp/modca/TagLogicalElement.java | 6 | ||||
-rw-r--r-- | src/java/org/apache/fop/afp/modca/triplets/AttributeValueTriplet.java | 13 |
2 files changed, 17 insertions, 2 deletions
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"); } |