iconv - Can php convert strings with all charset encodes to utf8 -


Can php convert strings with all charset encodes for utf8?

Solution that does not work:

  1. utf8_encode ($ string) - but its only an IOS-8859-1 String UTF-8?
  2. iconv ($ incharset, $ outcharset, $ text) - But how can string find current encoding? (Only when string part of html dom document, not just string)

thanks

>

It is possible to convert a string in UTF-8 to PHP in any iconv () in any encoding.

But how can this find string current encoding?

You do not need to "search" the current encoding: Your script should always know how it is If any resource asks you, if Is encoded properly, will give you its encoding in its content-type title or other ways.

As Artefacto says, there is a possibility of using mb_detect_encoding () but this is not a trusted way, the data flow of the program should always define what encoding in the string (And preferably internally working with UTF-8) - this is the way to go


Comments

Popular posts from this blog

paypal - How to know the URL referrer in PHP? -

oauth - Facebook OAuth2 Logout does not remove fb_ cookie -

wpf - Line breaks and indenting for the XAML of a saved FlowDocument? -