?
Solved

Formatting characters in RSS feed

Posted on 2007-08-09
16
Medium Priority
?
228 Views
Last Modified: 2013-11-18
Hello.

I'm using the ROME java api to create an RSS feed, and I'm having difficulty with the British Pound symbol.

The originating database entry has the normal pound sign (£). My feedwriter outputs the xml file, but on Unix based servers they don't like it, and it gets converted to something unusable. Looking at other popular rss feeds, such as the BBC, it seems the answer is to format your xml file to use the notation '& - # - 163 - ;' (dashes included in case the formatting is lost here too!). So ampersand, hash, 163, semi-colon.

I have confirmed this works when the feed is loaded into the browser, by editing the xml file by hand. But my problem is actually writing the file. When I do a replaceAll() call on all my pound signs, rather than writing the characters as described above, it converts the ampersand into the HTML equivalent - with the 'amp semi-colon' in it. So I end up with....

£  - which means nothing to the browser.

There must be a simple way around this - why is this happening, or what could I do instead?

Hope someone has some clues! Thanks.
0
Comment
Question by:whichit
  • 7
  • 4
  • 2
  • +1
14 Comments
 
LVL 20

Expert Comment

by:gatorvip
ID: 19663179
what is your actual call to replaceAll?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 19663182
Have you tried £
?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 19663190
>>rather than writing the characters as described above, it converts the ampersand into the HTML equivalent

What is 'it' here?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:whichit
ID: 19663234
The call to replaceAll is...

return in.replaceAll("£", "£");

Yes I have tried the £ notation, and strangely this breaks the xml feed (despite the fact that you can use other HTML equivalents like &.

When I say 'it' I mean the writer function within the ROME api...

<code>SyndFeedOutput output = new SyndFeedOutput();
output.output(feed, writer);</code>

At the point the text is entered to the feed object, it is correct, but once it is written, it's been converted.

Thanks for the comments so far...
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 19663286
           String s = "This is worth £££s";
            System.out.println(s.replaceAll("£", "&#163;"));

for me gives

This is worth &#163;&#163;&#163;s

so as you say it must be happening in 'output'. Please remind us what it gives again
0
 
LVL 20

Expert Comment

by:gatorvip
ID: 19663292
is "in" a String?

I tried a quick test

String s = "£££akhakhgaghag£kahahaaga";
s = s.replaceAll("£", "&#163;");
System.out.println(s);

As expected the output was
&#163;&#163;&#163;akhakhgaghag&#163;kahahaaga
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 19663324
Not sure it will help, but try making the Writer have UTF-8 encoding if it doesn't already
0
 

Author Comment

by:whichit
ID: 19663352
> so as you say it must be happening in 'output'. Please remind us what it gives again

It gives &amp;#163;

So it's pretty likely that as you say, this is something within the output - within the ROME configuration.

Concerning the encoding, I tried both UTF-8 and ended up settling with ISO-8859-1, as this was what other feeds seem to specify. I'll certainly try them again...
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 19663433
Did you call setEncoding on the feed too?
0
 

Author Comment

by:whichit
ID: 19663451
> Did you call setEncoding on the feed too?

Yes, using the formats mentioned above. It didn't make any difference.

I also experimented with setting the mime-type as either text/html or text/plain, but that had no bearing either.
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 1000 total points
ID: 19663512
I'd make 100% certain you know which component is causing this. Then you might need to did into its source
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 19663514
did=dig
0
 

Author Comment

by:whichit
ID: 19682341
Looks like I've exhausted people's ideas on this?

Which means I'll have to delve into the Rome source code, which I really didn't want to do!  :-/
0
 
LVL 1

Expert Comment

by:Computer101
ID: 20296348
Forced accept.

Computer101
EE Admin
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses
Course of the Month14 days, 11 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question