How to change a string to utf8 encoded?

I want to make a string to utf8 encoded, but I don't know what the original charset it is.

The original charset of string may be GBK, iso-8859-1, or others I don't know.

I use mb_detect_encoding($content, 'UTF-8', true) and iconv($original, "UTF-8", $content);

How to get the original encoding ?


ANSWERS:


I think this is maybe useful



 MORE:


 ? How can I post data with overlong encoding to test for vulnerabilities?
 ? How to set text file encoding in PHP?
 ? Transferring extended ascii characters with unknown encoding to a Twisted XMLRPC from C#
 ? Transferring extended ascii characters with unknown encoding to a Twisted XMLRPC from C#
 ? Transferring extended ascii characters with unknown encoding to a Twisted XMLRPC from C#
 ? how to: Twisted privmsg to accept non-ascii strings
 ? How to send XML-RPC request from XML-RPC callback in twisted
 ? Allowing any ASCII character transmitted in string with xmlrpc
 ? Rails 4: incompatible character encodings: UTF-8 and ASCII-8BIT
 ? twisted xmlrpc and numpy float 64 exception