This week's giveaway is in the
We're giving away four copies of
video training course and have Ken Kousen on-line!
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
video training course this week in the
XML and Related Technologies
Encoding Special case characters
Joined: Mar 11, 2002
Sep 28, 2004 05:08:00
Sorry if this is posted elsewhere, i've had a look and can't find it.
I'm creating a
via FOP, from user data so I need to include provisions for < > & etc...
I know i need to encode the characters into xxx; format, and I can write a class to do this.
However is there a built in method somewhere, like the URLEncode.Encode? or should i use this and a regular expression to replace %84 with the format i need?
I'm using the bog standard UTF-8 encoding.
Any Help / comments would be appreciated.
Author and all-around good cowpoke
Joined: Mar 22, 2000
Sep 28, 2004 07:54:00
I used a whole lot of java.util.regex
objects - precompiled as static variables.
static Pattern ampRep = Pattern.compile("&"); static Pattern ltRep = Pattern.compile("<"); static Pattern gtRep = Pattern.compile(">");
with code like this....
tmp = ampRep.matcher( tmp ).replaceAll( "&" );
I have no idea whether this is a fast way, but it worked for me.
Joined: Mar 11, 2002
Sep 29, 2004 03:15:00
Thanks for the help there... But I found a more elegant way to catch the issue.
Instead of translating the needed characters in code I've left it up to the processor by wrapping the text data in cdata tags.
<![CDATA[MR & MRS SMITH]]>
This means I don't have to write code for each special case character and hasn't impacted the speed of which the PDF is created.
I agree. Here's the link:
subject: Encoding Special case characters
Need help for convert Hex Unicode to HTML codes?
Generating PDF with special characters
Including special characters in an XML which is validated against a schema
Writing to a Property File
Problems with Unicode characters, when I use this API Rtf.Template
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015