473,405 Members | 2,444 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

trying to make characters safe for my RSS feed

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, without causing anyone's newsfeed
reader to die.
function command($string=false) {
$howMany = strlen($string);

$newString = "";
for ($i=0; $i < $howMany; $i++) {
$char = $string[$i];
$asciiNum = ord($char);
if ($asciiNum > 32 && $asciiNum < 128) {
$newString .= $char;
} else {
$newString .= "'";
}
}

return $newString;
}

Oct 10 '05 #1
4 1885
Okay, the function doesn't work:

http://www.whatisliberalism.com/pdsFiles/page2533.xml

All the white space got replaced, but the entity that is kill the feed
is still there.

What is wrong with this function?

function command($string=false) {
$howMany = strlen($string);

$newString = "";
for ($i=0; $i < $howMany; $i++) {
$char = $string[$i];
$asciiNum = ord($char);
if ($asciiNum > 32 && $asciiNum < 128) {
$newString .= $char;
} else {
$newString .= "'";
}
}

return $newString;
}

Oct 10 '05 #2
lk******@geocities.com wrote:
Okay, the function doesn't work:

http://www.whatisliberalism.com/pdsFiles/page2533.xml

All the white space got replaced, but the entity that is kill the feed
is still there.

What is wrong with this function?

function command($string=false) {
$howMany = strlen($string);

$newString = "";
for ($i=0; $i < $howMany; $i++) {
$char = $string[$i];
$asciiNum = ord($char);
if ($asciiNum > 32 && $asciiNum < 128) {
$newString .= $char;
} else {
$newString .= "'";
}
}

return $newString;
}

I don't know what's wrong with its operation, but you're reinventing the
wheel.

Have a look at http://uk2.php.net/manual/en/function.strtr.php

Colin
Oct 13 '05 #3
>>>All the white space got replaced, but the entity that is kill the
feed
is still there.
What is wrong with this function?
function command($string=false) {
$howMany = strlen($string);
$newString = "";
for ($i=0; $i < $howMany; $i++) {
$char = $string[$i];
$asciiNum = ord($char);
if ($asciiNum > 32 && $asciiNum < 128) {
$newString .= $char;
} else {
$newString .= "'";
}
}
return $newString;
}

I don't know what's wrong with its operation, but you're
reinventing the
wheel.

Have a look at http://uk2.php.net/manual/en/function.strtr.php


I apologize for my ignorance, but I don't see how that reinvents the
wheel. The function you point to would allow me to replace the
offending character if I knew what it was, but I don't know what it
is.That's why I'm walking through the string one character at a time,
checking its ASCII number. Yet even that isn't working. I can't figure
out why. But that's the question.

Oct 25 '05 #4
All the white space got replaced, but the entity that is kill the
feed
is still there.


&acirc; XML is not HTML.

---
Steve

Oct 25 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: lkrubner | last post by:
I've a client who, I think, writes his essays in Microsoft Word on a Macintosh, then copies and pastes it to a form to upload it to his weblog. The weblog then creates an RSS feed. The weblog and...
6
by: barthome1 | last post by:
Hello, My company collects data from non-US sources. We are starting projects where this data will be output in an XML document and passed around to our applications and third party tools. ...
35
by: Durgesh Sharma | last post by:
I want to use strrchar(source_string,last_char ) function from string.h header file,to find out the last occurrence of the NON SPACE Alphanumeric Character. Then i will put a NULL CHAR after...
2
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...
1
by: Programmer | last post by:
I have this following code: x= tempStr.IndexOf((char)13, 0); The string tempSTR = " Heading"
4
by: randy1200 | last post by:
Using Visual Studio 2005. I'm using XmlReader to read data into a string variable in C#. Works great! Every once in a while, I see that the string data contains a symbol that looks like a...
1
by: Adam W. | last post by:
So I wrote a little video podcast downloading script that checks a list of RSS feeds and downloads any new videos. Every once in a while it find a character that is out of the 128 range in the...
14
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...
13
by: Liang Chen | last post by:
Hope you all had a nice weekend. I have a question that I hope someone can help me out. I want to run a Python program that uses Tkinter for the user interface (GUI). The program allows me to type...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
tracyyun
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.