CaRP: Caching RSS Parser - Documentation
CaRP Interactive FAQ
Getting Started: Free Download | Purchase | Install
Reference: Functions | Plugins | Themes | Full Index
Etc.: Display Formatting | Example Code | Affiliates
Getting Started: Free Download | Purchase | Install
Reference: Functions | Plugins | Themes | Full Index
Etc.: Display Formatting | Example Code | Affiliates
Transcode
XML character encoding converter utilityGPL | Koi | Evolution |
n/a | 3.5.7 - 3.5.11 | 3.5.7 - 3.5.11 |
As of version 3.6, Transcode's functionality has been integrated into CaRP Koi and CaRP Evolution. Transcode is a PHP script (transcode.php) that converts XML documents from one encoding to another. It is useful for processing XML documents in PHP scripts when the "charset" of the source document is not one of the encodings supported by PHP's built-in XML parser (UTF-8, ISO-8859-1 and US-ASCII). Transcode is bundled with CaRP Koi and CaRP Evolution.
Requirements:
Transcode requires iconv support, and support for opening remote files using PHP's "fopen" function. To find out whether Transcode will work on your server, upload it to your server and then load the following URL in your web browser, substituting your domain name and the path to your copy of transcode.php in at the beginning of the URL:
http://www.YOUR-WEBSITE.com/PATH/transcode.php?url=http://rss.geckotribe.com/rss/0.rss
If you see an error message about the fopen function failing or iconv being an unknown function, then your server does not support Transcode.
Limitations:
- For security purposes, Transcode will not open local files--the URL of the document to be converted must begin with "http://" or "https://".
- Although Transcode can convert feeds in languages like Chinese and Japanese which use multibyte characters, CaRP is not internally multibyte aware. When truncating text containing multibyte characters (for example, based on the maxidesc setting), CaRP will truncate after the specified number of bytes rather than characters, and may truncate in the middle of a multibyte character.
- Transcode is not able to access password protected documents.
- To use Transcode through a proxy server,
you will need to add the proxy server address to the beginning of the feed URL,
for example:
http://example.org/transcode.php?url=http://proxy-server.com/http://example.com/feed.rss
Configuration:
If you wish to limit the IP addresses from which Transcode may be executed (for example, to only allow your own server to use it so that random people don't use up your bandwidth converting their own documents), find this line near the top of transcode.php:
$allow_from=array();
List any IP addresses which you wish to allow into the array. Two examples follow:
only allow one IP address:
$allow_from=array('192.168.0.1');
allow any of the specified IP addresses:
$allow_from=array('192.168.0.1','192.168.0.2','10.0.0.15');
Installation:
After configuring Transcode, simply upload it to your webserver.
Use: To convert a document, load transcode.php from your webserver, with the URL of the feed you want to convert specified like this (Note that for security purposes, Transcode will refuse to process local files--the URL must begin with http:// or https://. "https" URLs are not supported by all servers):
http://www.example.com/transcode.php?url=http://www.example.org/feed.xml
By default, Transcode converts to the UTF-8 character set (which is the default encoding for XML documents). You can change this behavior by specifying the target encoding like this:
http://www.example.com/transcode.php?url=http://www.example.org/feed.xml&encodingout=ISO-8859-1
If the document doesn't specify it's character set in the XML prologue (the first line of an XML document), you'll need to find out what it is and add it to the URL like this:
http://www.example.com/transcode.php?url=http://www.example.org/feed.xml&encodingin=EUC-JP
Usage Example with CaRP:
Notice how the URL of the feed is placed inside a call to "urlencode". This ensures that the "&" in the feed URL is properly encoded. Otherwise, Transcode would think that the URL of the feed was "http://www.example.com/feed.php?feed_id=10", and that "items=15" was one of Transcode's own settings.
Also notice that CaRP has been told to output UTF-8. This is usually necessary if the source feed contains characters that aren't used in English, because CaRP's default output encoding (ISO-8859-1 -- which is PHP's default encoding) only contains letters and symbols used in English.
<?php require_once '/home/geckotribe/carp/carp.php'; CarpConf('encodingout','UTF-8'); CarpCacheShow('http://www.example.com/transcode.php?url='.urlencode('http://www.example.org/feed.php?feed_id=10&items=15')); ?>