Character encoding
am 05.08.2009 13:05:05 von sandortamas
------=_NextPart_000_003B_01CA15CD.5A090520
Content-Type: text/plain;
charset="iso-8859-2"
Content-Transfer-Encoding: quoted-printable
Hi,
I have a mysql database, which the users can insert comments. As the =
users can be from different countries, with different character =
encoding, the mysql table can contain various special characters.
How can I be sure to display these comments properly? I've found the =
mb_convert_encoding, and for some characters it works okay, but there =
are some really special characters which displayed as a '?'.
Does anybody know some workarounds?
Thanks,
SanTa
------=_NextPart_000_003B_01CA15CD.5A090520--
Re: Character encoding
am 05.08.2009 17:44:02 von B
On 08/05/2009 07:05 AM, Sándor Tamás (HostWare Kft.) wrote:
> Hi,
>
> I have a mysql database, which the users can insert comments. As the users can be from different countries, with different character encoding, the mysql table can contain various special characters.
>
> How can I be sure to display these comments properly? I've found the mb_convert_encoding, and for some characters it works okay, but there are some really special characters which displayed as a '?'.
>
> Does anybody know some workarounds?
>
> Thanks,
> SanTa
Use UTF-8. Create your database and its tables with UTF-8 char encoding. eg.
ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
Note there's no hyphen.
Also, make sure the *data* is converted. You can use iconv for that.
Next, ensure that the browser knows how to display the text. Use either
a header or a meta tag (or both):
This is especially important for the page with the comments form.
Any SQL file with your data (for import) should have the following at
the top:
SET NAMES 'utf8';
If you export a dump make sure that line is present before trying to import.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Character encoding
am 05.08.2009 18:01:50 von Igor Escobar
--0015175cb2f4f71e160470671e6d
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Build some script to convert to these comments.
Check this out:
// Fixes the encoding to uf8
function fixEncoding($in_str)
{
$cur_encoding =3D mb_detect_encoding($in_str) ;
if($cur_encoding == "UTF-8" && mb_check_encoding($in_str,"UTF-8"))
return $in_str;
else
return utf8_encode($in_str);
} // fixEncoding
?>
Regards,
Igor Escobar
Systems Analyst & Interface Designer
+ http://blog.igorescobar.com
+ http://www.igorescobar.com
+ @igorescobar (twitter)
2009/8/5 b
> On 08/05/2009 07:05 AM, S=E1ndor Tam=E1s (HostWare Kft.) wrote:
>
>> Hi,
>>
>> I have a mysql database, which the users can insert comments. As the use=
rs
>> can be from different countries, with different character encoding, the
>> mysql table can contain various special characters.
>>
>> How can I be sure to display these comments properly? I've found the
>> mb_convert_encoding, and for some characters it works okay, but there ar=
e
>> some really special characters which displayed as a '?'.
>>
>> Does anybody know some workarounds?
>>
>> Thanks,
>> SanTa
>>
>
> Use UTF-8. Create your database and its tables with UTF-8 char encoding.
> eg.
>
> ENGINE=3DMyISAM DEFAULT CHARSET=3Dutf8 COLLATE=3Dutf8_unicode_ci
>
> Note there's no hyphen.
>
> Also, make sure the *data* is converted. You can use iconv for that.
>
> Next, ensure that the browser knows how to display the text. Use either a
> header or a meta tag (or both):
>
>
/>
>
> This is especially important for the page with the comments form.
>
> Any SQL file with your data (for import) should have the following at the
> top:
>
> SET NAMES 'utf8';
>
> If you export a dump make sure that line is present before trying to
> import.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--0015175cb2f4f71e160470671e6d--
Re: Character encoding
am 05.08.2009 18:11:44 von Ralph Deffke
I assume that the comments are collected by a browser form provided by you !
do u use the form attribute "accept-charset" ? I always do and I always use
UTF-8 homogeniously throughout my application I never had that problem.
"Sándor Tamás (HostWare Kft . )" wrote in message
news:9AC01674E03A4D76A1B49DAD39B04E31@STGEPE...
Hi,
I have a mysql database, which the users can insert comments. As the users
can be from different countries, with different character encoding, the
mysql table can contain various special characters.
How can I be sure to display these comments properly? I've found the
mb_convert_encoding, and for some characters it works okay, but there are
some really special characters which displayed as a '?'.
Does anybody know some workarounds?
Thanks,
SanTa
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Character encoding
am 05.08.2009 18:43:38 von news.NOSPAM.0ixbtqKe
On Wed, 5 Aug 2009 18:11:44 +0200, "Ralph Deffke" wrote:
> I assume that the comments are collected by a browser form provided by you !
> do u use the form attribute "accept-charset" ? I always do and I always use
> UTF-8 homogeniously throughout my application I never had that problem.
Don't forget to read the late Alan J. Flavell's pages
on character sets and internationalization.
/Nisse
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php