views:

146

answers:

1

Hello,

I'm trying to get HTML meta tags with PHP by using get_meta_tags() function. I'm using UTF8 for tables, charset/collations, as connection charset to MySQL and everything else.

But unfortunetely MySQL cuts off the string when inserting to table. It happens while HTML encodings are different than UTF-8 (for example ISO 8859-1)

Is there any way for converting strings to UTF8 without knowing it's encoding charset?

A: 

Encodes an ISO-8859-1 string to UTF-8 (PHP 3 >= 3.0.6, PHP 4, PHP 5)

string utf8_encode ( string data )

Convert string to requested character encoding (PHP 4 >= 4.0.5, PHP 5)

string iconv ( string in_charset, string out_charset, string str )

However, if you want to change to UTF-8 regardless of encoding, checkout;

Convert character encoding (PHP 4 >= 4.0.6, PHP 5)

string mb_convert_encoding ( string str, string to_encoding [, mixed from_encoding] )

r0ash
You can also check what encoding is being used with string mb_detect_encoding ( string str [, mixed encoding_list [, bool strict]] )
r0ash