Forum

Thread tagged as: Problem, Runway, Blog

RSS encoding and whitespace

Hello, trying to create an RSS feed for a blog, I'm using the default rss.php and rss_post.html. The only change I've made is pulling some block contents like this

<item>
    <title>
        <perch:blog id="postTitle" />
    </title>
    <link>
        <perch:blog id="domain" /><perch:blog id="postURL" />
    </link>
    <guid>
        <perch:blog id="domain" /><perch:blog id="postURL" />
    </guid>
    <description><perch:if exists="postDescHTML"><![CDATA[<perch:blog id="postDescHTML" encode="false" />]]><perch:else /><![CDATA[<perch:blocks><perch:block type="text" label="Texto"><div class="simpletext__base simpletext--editor">
    <perch:content id="simple-text" type="textarea" label="Texto Simple" html="false" escape="true" />
</div></perch:block><perch:block type="image" label="Imagen"><perch:template path="blog/body_image.html" /></perch:block><perch:block type="list" label="listado"><perch:template path="content/list.html" rescope="parent" /></perch:block></perch:blocks>]]></perch:if>
    </description>
    <pubDate>
        <perch:blog id="postDateTime" format="D, d M Y H:i:s O" />
    </pubDate>
</item>

The main problem is that special characters appear with wrong encoding. For example continuación and También instead of continuación and También. Adding encoding="utf-8" on the top of the feed makes no difference. I'm completely confused with Windows-1252, ISO 8859-1 and so on.

The second and minor issue is that there are some huge white spaces between html tags in the description output.

Could you please help?

Proko Mountrichas

Proko Mountrichas 3 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

What encoding is your server sending in the http headers?

I don't see anything related to encoding in the Response Headers. Does this help?

Headers

Drew McLellan

Drew McLellan 2638 points
Perch Support

I don't have permission to view that image.

Updated, sorry!

Drew McLellan

Drew McLellan 2638 points
Perch Support

Try:

 header('Content-Type: application/rss+xml; charset=utf-8');

Great! Encoding is ok now.

Do you think white spaces could be equally easy to address?

Edit: No worries I will do a post processing/formatting.