|
Posted by Andy Hassall on 06/13/07 21:15
On Wed, 13 Jun 2007 22:25:44 +0200, "amygdala" <noreply@noreply.com> wrote:
>I'm trying to let PHP write a 'sitemap.xml' sitemap for Google and other
>searchengines. It's working, except that the content in the XML file doesn't
>seem to be UTF8. (Which it should be, judging by the information given on
>Google's webmaster helpcenter).
>
>The way I test to see if the content is UTF8, is by opening the XML file in
>notepad and choose 'save as...'. Normally the coding option should be set to
>UTF8, but now it just shows ANSI.
Well, that's not a foolproof method...
>This is what I have tried to write UTF8 content with:
>
>file_put_contents( '.' . SITEMAP_FILE, utf8_encode(
>$this->sitemapForCrawlers ) );
>...and...
>file_put_contents( '.' . SITEMAP_FILE, iconv( "ISO-8859-1", "UTF8",
>$this->sitemapForCrawlers ) );
>
>...where...
>SITEMAP_FILE is the filename constant
>...and...
>$this->sitemapForCrawlers is the string with XML data
>
>With the last attempt I even got an error saying:
>
>Wrong charset, conversion from `ISO-8859-1' to `UTF8' is not allowed in...
>
>Any adeas of how I can make this work?
Start from the beginning; what character set encoding is the original data in?
The error implies that it's not ISO-8859-1 (which does have some gaps where
characters aren't valid...)
--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Navigation:
[Reply to this message]
|