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;
} 4 1898
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;
} lk******@geocit ies.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
>>>All the white space got replaced, but the entity that is kill the feedis 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. All the white space got replaced, but the entity that is kill the feed is still there.
â XML is not HTML.
---
Steve This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 RSS feed
are created using a simple PHP script I wrote.
His RSS feed is not validating, apparently because of the Word "smart
quotes". This is a guess on my part. I need to find out for sure what
character is causing the rss failure. How do I do...
|
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.
The data includes some of the extended characters. We get strange
accent marks, italics and the like. These characters have decimal
value in the 200+ range.
|
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 incrementing that position,received
by strrchar() function by 1.
This is my idea of Trimming a string from right .
According to the definition of the strrchar function,i am supposed to
|
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: Programmer |
last post by:
I have this following code:
x= tempStr.IndexOf((char)13, 0);
The string tempSTR = "
Heading"
| |
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 square.
Any suggestions on how to filter out characters that don't appear on a
keyboard? I hate to let the end-user see these square characters.
--
|
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 feed and my
script blows up:
Traceback (most recent call last):
File "C:\Users\Adam\Desktop\Rev3 DL\Rev3.py", line 88, in <module>
mainloop()
File "C:\Users\Adam\Desktop\Rev3 DL\Rev3.py", line 75, in mainloop
update()
|
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: 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 Chinese characters, but neverthelss is unable to show them up on screen. The follow is some of the error message I received after I logged off the program:
"Could not write output: <type "exceptions: UnicodeEncodeError'>, 'ascii' codec can't...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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: 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: 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...
| |