Hi,
I've created a utf8 encoded RSS feed which presents news data drawn from a database. I've set all aspects of my database to utf8 and also saved the text which i have put into the database as utf8 by pasting it into notepad and saving as utf8. So everything should be encoded in utf8 when the RSS feed is presented to the browser, however I am still getting the wierd question mark characters for pound signs :(
Here is my RSS feed code (coldfusion): -
<cfsilent>
-
<!--- Get News --->
-
<cfinvoke component="com.news" method="getAll" dsn="#Request.App.dsn#" returnvariable="news" />
-
</cfsilent>
-
<!--- If we have news items --->
-
<cfif news.RecordCount GT 0>
-
<!--- Serve RSS content-type --->
-
<cfcontent type="application/rss+xml">
-
<!--- Output feed --->
-
<cfcontent reset="true"><?xml version="1.0" encoding="utf-8"?>
-
<cfoutput>
-
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
-
<channel>
-
<title>News RSS Feed</title>
-
<link>#Application.siteRoot#</link>
-
<description>Welcome to the News RSS Feed</description>
-
<lastBuildDate>Wed, 19 Nov 2008 09:05:00 GMT</lastBuildDate>
-
<language>en-uk</language>
-
<atom:link href="#Application.siteRoot#news/rss/index.cfm" rel="self" type="application/rss+xml" />
-
-
<cfloop query="news">
-
<!--- Make data xml compliant --->
-
<cfscript>
-
news.headline = replace(news.headline, "<", "<", "ALL");
-
news.body = replace(news.body, "<", "<", "ALL");
-
news.date = dateformat(news.date, "ddd, dd mmm yyyy");
-
news.time = timeformat(news.time, "HH:mm:ss") & " GMT";
-
</cfscript>
-
<item>
-
<title>#news.headline#</title>
-
<link>#Application.siteRoot#news/index.cfm?id=#news.id#</link>
-
<guid>#Application.siteRoot#news/index.cfm?id=#news.id#</guid>
-
<pubDate>#news.date# #news.time#</pubDate>
-
<description>#news.body#</description>
-
</item>
-
</cfloop>
-
</channel>
-
</rss>
-
</cfoutput>
-
<cfelse>
-
<!--- If we have no news items, relocate to news page --->
-
<cflocation url="../news/index.cfm" addtoken="no">
-
</cfif>
-
Has anyone any suggestions? I've done loads of research but can't find the right answers :(
Thanks in advance,
Chromis
7 4312 Dormilich 8,658
Recognized Expert Moderator Expert
does it help if you use £? (I know that may be only a workaraound, but from the code I can tell nothing without the actual feed)
is £ the only character outside the ascii charset? maybe your generator has some problems with utf-8 or doesn't know which charset to use....
regards
PS please don't post your questions in the insights section, ask a moderator to move it to the answers section.
Hi Dormilich thanks for your reply. My apologies, I am aware of the answers section but I accidentally put it in here, it's very easy to make the mistake sadly (preffered the old layout!).
Yes the only bad character is the pound sign, I've tryed replacing it manually in the database presuming that that would replace the chracter with the utf8 equivalent but it didn't work. If i use the £ it breaks the feed. I could use cdata but I need to display paragraph formatting, and using cdata displays the p element tags.
Dormilich 8,658
Recognized Expert Moderator Expert
£ breaks your feed because it's an undefined entity (you'd need a DTD to fix that). have you tried £? this should not break the feed.
regards
Ok i've replaced all occurences of £ with £ it now works great thanks! Why would the pound sign not be recognised though, do you think that when i saved the file as utf8 it didn't convert the character properly?
Ideally i would like to create a function in coldfusion which will doctor text and make it utf8 compliant, do you know of the best way to do this?
I am most of the way there with the following function, apart from putting some code in to replace the pound signs what other ways could i improve it? -
<cfcomponent>
-
<cffunction name="CustomParagraphFormatXMLSafe" access="public" returntype="string">
-
<cfargument name="paragraph" type="string" required="yes">
-
-
<cfscript>
-
/**
-
* Returns a XHTML string suitable for insertion into a database in the UTF-8 encoding format.
-
* The string is then wrapped with opening and closing paragraph tags whilst ignoring list elements.
-
*
-
* @param paragraph String you want XHTML / XML formatted.
-
* @return Returns a string.
-
* @author ****
-
* @version 1.0, December 10th, 2008
-
*/
-
-
var returnValue = '';
-
var newParagraph = arguments.paragraph;
-
var sqlList = "-- ,'";
-
var replacementList = "#chr(38)##chr(35)##chr(52)##chr(53)##chr(59)##chr(38)##chr(35)##chr(52)##chr(53)##chr(59)# , #chr(38)##chr(35)##chr(51)##chr(57)##chr(59)##chr(163)#";
-
-
/* Replace pound signs */
-
Replace(newParagraph,"£","£");
-
-
/* Make sql safe */
-
newParagraph = trim(replaceList( newParagraph , sqlList , replacementList ));
-
-
/* Make XML and UTF-8 Safe */
-
newParagraph = XMLFormat(CharsetEncode(CharsetDecode(newParagraph,"utf-8"),"utf-8"));
-
-
/* Break into paragraphs */
-
newParagraph = ListToArray(newParagraph,Chr(13) & Chr(10));
-
newParagraphCount = ArrayLen(newParagraph);
-
-
for(i=1;i LTE newParagraphCount;i=i+1) {
-
-
//WriteOutput(newParagraph[i]);
-
-
/* Ignore blank lines */
-
if(newParagraph[i] NEQ "") {
-
-
/* Remove excess paragraph elements */
-
REReplace(newParagraph[i], "<?p*>", "", "All");
-
-
/* Loop through array of paragraphs wrapping in p elements, skipping list elements */
-
containsList = REFind("<\/?ul[^>]*>$|<\/?li[^>]*>",newParagraph[i]); //
-
if(containsList EQ 0) {
-
returnValue = returnValue & "<p>" & newParagraph[i] & "</p>" & Chr(13) & Chr(10);
-
}
-
else {
-
returnValue = returnValue & newParagraph[i] & Chr(13) & Chr(10);
-
}
-
}
-
}
-
return trim(returnValue);
-
</cfscript>
-
</cffunction>
-
</cfcomponent>
-
Dormilich 8,658
Recognized Expert Moderator Expert @chromis
this is a question more suited in the coldfusion forum. I have never used CF and I'm probably no help there....
regards
Ok thanks anyway, i'll ask in the cf forum.
Frinavale 9,735
Recognized Expert Moderator Expert
I've moved your thread to the ColdFusion forum.
Hopefully you'll get more help here.
-Moderator Frinny
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: lawrence |
last post by:
I'm running this page:
http://www.krubner.com/rss/page938.xml
through this validator:
http://rss.scripting.com/?url=http%3A%2F%2Fwww.krubner.com%2Frss%2Fpage938.xml
|
by: lkrubner |
last post by:
Whenever users write a post in Microsoft Word and then post it to
their weblogs using my PHP software, their RSS feed ends up being
corrupted with garbage characters which violate the well-formedness of
their XML and therefore cause their newsreaders to die.
This function will probably make the character strings completely safe
for XML? I don't care about having garbage characters in the RSS feed,
I just want the RSS feed to show up,...
|
by: intl04 |
last post by:
I have a memo field that is included in some Access reports I created.
Is there some way for the memo field to display nicely formatted text,
with line breaks between paragraphs? Or is it necessary to export the
report?
I tried exporting a report by using the .rtf rich-text format (the
plain-text format was the only other word-processing option listed
when exporting). I then opened the .rtf file in Word. However, it
looks like some...
|
by: Sathyaish |
last post by:
A practice excercise from K&R. Kindly read the comments within the
program. I'd be very grateful to people who helped. Why is it that I
get the wierd face-like characters on the screen instead of the
boolean output 0s or 1s?
#include <stdio.h>
/*This program is made to check that leaving the brackets around the
epxression (c=getchar()) in
the statement while ((c=getchar()) !=EOF) produces a boolean output in
|
by: Buddy Ackerman |
last post by:
Apparently .NET strips these white space characters (MSXML doesn't)
regardless of what the output method is set to. I'm using
<xsl:text> </xsl:text> to output a tab character and
<xsl:text>
</xsl:text> to output a carriage return and line feed
but they get stripped at some point. I'm passing a StringWriter to the
XslTransform.Transform method. Anyway to get this to actually output the
tab and carriage and line feed characters?
| |
by: lawrence k |
last post by:
2 years ago I asked, on this newsgroup, how to weed out non-UTF-8
characters from my RSS feed. I was told that I could not do so with
certainty, but I could try various tricks that would give me maybe
99%. I notice, however, that XML parsers seem to have 100% certainty
when they find bad characters. Consider the last error that I get from
this validation service:
...
|
by: =?Utf-8?B?RGlmZmlkZW50?= |
last post by:
Hi All,
I have created an RSS feed reader. However, the feed that I am trying to
read has some invalid characters which my reader does not like. I have no
control on the RSS feed but I would like to be able to read the feed.
Is there a way I could handle these invalid characters and replace them with
something else in my reader?
Thanks for your suggestions!
|
by: jt |
last post by:
hello everyone..,
i'm using ubuntu 8.04 OS. I'm not able to output the non-printable
ascii chatacters.
for eg.
printf("%c",1); // nothing is outputted.....
is there any way to output these characters...???
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
| |
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |