Hi there.
I've been doing some string manipulation using the Ethernet shield and TextFinder for output onto an 8x8 RGB Matrix.
I can reliably pull an RSS news item like this:
if (client.connected()) {
strcpy_P(buffer, (char*)pgm_read_word(&(string_table[14]))); // "title data="
finder.find(buffer);
for (int i = 0; i < randomInt; i++) {
if (finder.getString(buffer,"\"", newsString, 84)) {
}
}
The feed displays just fine on the matrix.
But the news item is not clean text. It occasionally has "smart quotes" in it. These appear in the feed as "&#39;" in the displayed feed.
I want to replace the ugliness with a simple quote, '.
So, after searching high and low for a reliable replace function, I stumbled on the one right under my nose: String.replace.
However, the feed is dumped into char newsString[]. In order to use .replace, I need a String, so:
// Make a new string.
String d = String(85);
//Replace the HTML nastiness with a single '
d = String(newsString).replace("&amp39;", "\'");
But then in order to display the information, I need to have a char again. So:
d.toCharArray(newsString, 84);
Kaboom. The board freezes or resets itself.
Inserting debug statements shows that the replace is actually reached.
It feels like I'm misusing or incorrectly calling the .replace or handling the array badly.
Can anyone point me in the right direction?
Cheers,