CaRP: Caching RSS Parser - Documentation
XML character encoding converter utility
As of version 3.6, Transcode's functionality has been integrated into CaRP Koi and CaRP Evolution.
||3.5.7 - 3.5.11
||3.5.7 - 3.5.11
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.
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:
If you see an error message about the fopen function failing or iconv being an unknown function,
then your server does not support Transcode.
- 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,
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:
List any IP addresses which you wish to allow into the array.
Two examples follow:
only allow one IP address:
allow any of the specified IP addresses:
After configuring Transcode, simply upload it to your webserver.
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):
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:
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:
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.