FeedForAll Forum Index  
 Home  •  FAQ  •   Search   •  Register   •  Profile   •  Log in
 iconv View next topic
View previous topic
Post new topicReply to topic
Author Message
wombat



Joined: 21 Mar 2007
Posts: 3

PostPosted: Wed Mar 21, 2007 1:32 pm Reply with quoteBack to top

Hi

My MySQL data is has iso-8859-1 encoding. How can I use iconv to convert the data to utf-8? Where do I implement it in the code?

Thanks in advance!

Wombat
View user's profile
MacSupport



Joined: 24 Feb 2005
Posts: 2805

PostPosted: Wed Mar 21, 2007 1:41 pm Reply with quoteBack to top

wombat wrote:
Hi

My MySQL data is has iso-8859-1 encoding. How can I use iconv to convert the data to utf-8? Where do I implement it in the code?

Thanks in advance!

Wombat


The simplest solution would be to change the specified charset in the xml definition to "iso-8859-1".

Here is the code I use in rss2html.php, with some variables replaced with constants for you.

Code:
if (($newResult = iconv("iso-8859-1", "UTF-8//TRANSLIT", $workString)) !== FALSE) {
  return $newResult;
}


To put this code to use, I would put it in sql2rss_substition(), on line 134 by replacing "return $text;" with.

Code:
if (($newResult = iconv("iso-8859-1", "UTF-8//TRANSLIT", $text)) !== FALSE) {
  return $newResult;
}
return $text;


Jim

_________________
Be sure to check out the FeedForAll Mac tutorials at: http://www.FeedForAll.com/tutorials/

FeedForAll Mac and rss2html.php
support@FeedForAll.com
View user's profileVisit poster's website
wombat



Joined: 21 Mar 2007
Posts: 3

PostPosted: Wed Mar 21, 2007 2:17 pm Reply with quoteBack to top

Hi and thanks for the reply.

I replaced the only return $text; in sql2rss.php with
Code:

if (($newResult = iconv("iso-8859-1", "UTF-8", $text)) !== FALSE) {
  return $newResult;
}
return $text;
}


Unfortunately it didn't work. Here is the link to the feed.
View user's profile
MacSupport



Joined: 24 Feb 2005
Posts: 2805

PostPosted: Wed Mar 21, 2007 5:33 pm Reply with quoteBack to top

wombat wrote:
Hi and thanks for the reply.

I replaced the only return $text; in sql2rss.php with
Code:

if (($newResult = iconv("iso-8859-1", "UTF-8", $text)) !== FALSE) {
  return $newResult;
}
return $text;
}


Unfortunately it didn't work. Here is the link to the feed.


Are you sure iconv is even installed in the PHP libraries on your system? There are also the mb_string* functions. For that use:
Code:
if (($newResult = mb_convert_encoding($text,  "UTF-8", "ISO-8859-1")) !== FALSE) {
  return $newResult;
}
return $text;


Jim

_________________
Be sure to check out the FeedForAll Mac tutorials at: http://www.FeedForAll.com/tutorials/

FeedForAll Mac and rss2html.php
support@FeedForAll.com
View user's profileVisit poster's website
wombat



Joined: 21 Mar 2007
Posts: 3

PostPosted: Thu Mar 22, 2007 11:47 am Reply with quoteBack to top

MacSupport wrote:

Are you sure iconv is even installed in the PHP libraries on your system? There are also the mb_string* functions. For that use:


Yes, iconv is installed, I use it in a few other scripts. The last suggestion didn't work either. Same result as last time.

Wombat
View user's profile
MacSupport



Joined: 24 Feb 2005
Posts: 2805

PostPosted: Thu Mar 22, 2007 12:07 pm Reply with quoteBack to top

wombat wrote:
Yes, iconv is installed, I use it in a few other scripts. The last suggestion didn't work either. Same result as last time.

Wombat


Replied via email

Jim

_________________
Be sure to check out the FeedForAll Mac tutorials at: http://www.FeedForAll.com/tutorials/

FeedForAll Mac and rss2html.php
support@FeedForAll.com
View user's profileVisit poster's website
mkp



Joined: 01 Sep 2010
Posts: 6

PostPosted: Tue Nov 02, 2010 12:13 pm Reply with quoteBack to top

I have always been a regular reader of this blog. In fact I was having the same problem as mentioned by wombat. I also wanted to use iconv to convert the data to utf-8. Unfortunately up till now I am not able to solve that. In fact I did all the steps mentioned by MacSupport but to no avail. I hope that he will give us a detailed reply through this blog to help me. I would like to thank him in advance.
View user's profile
mkp



Joined: 01 Sep 2010
Posts: 6

PostPosted: Fri Nov 19, 2010 7:00 am Reply with quoteBack to top

Any Update ?

_________________
smart card
View user's profile
Display posts from previous:      
Post new topicReply to topic


 Jump to:   



View next topic
View previous topic


Powered by phpBB © 2001, 2002 phpBB Group :: FI Theme