Author |
Message |
wombat
Joined: 21 Mar 2007
Posts: 3
|
Posted:
Wed Mar 21, 2007 1:32 pm |
  |
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 |
|
|
 |
 |
MacSupport
Joined: 24 Feb 2005
Posts: 2805
|
Posted:
Wed Mar 21, 2007 1:41 pm |
  |
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 |
|
  |
 |
wombat
Joined: 21 Mar 2007
Posts: 3
|
Posted:
Wed Mar 21, 2007 2:17 pm |
  |
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. |
|
|
 |
 |
MacSupport
Joined: 24 Feb 2005
Posts: 2805
|
Posted:
Wed Mar 21, 2007 5:33 pm |
  |
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 |
|
  |
 |
wombat
Joined: 21 Mar 2007
Posts: 3
|
Posted:
Thu Mar 22, 2007 11:47 am |
  |
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 |
|
|
 |
 |
MacSupport
Joined: 24 Feb 2005
Posts: 2805
|
Posted:
Thu Mar 22, 2007 12:07 pm |
  |
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 |
|
  |
 |
mkp
Joined: 01 Sep 2010
Posts: 6
|
Posted:
Tue Nov 02, 2010 12:13 pm |
  |
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. |
|
|
 |
 |
mkp
Joined: 01 Sep 2010
Posts: 6
|
Posted:
Fri Nov 19, 2010 7:00 am |
  |
|
 |
 |
|