Index

(misc)

o2_encode

string o2_encode(string $string, string $encoding)

Returns passed string translated to the current application character encoding or to a passed one.
Translation is applied only when needed, according with string and target encoding.
Encoding to UTF-8, passed string can be mixed-encoded (UTF-8 and Win1252) and only needing parts (Win1252) will be converted.
So it's safe to do o2_encode(o2_encode($string)).
In most cases, especially running UTF-8 applications, you'll never need to pass the second parameter $encoding.
This second parameter can come in handy when you are runnning Win1252 applications and you want to produce UTF-8 output from mixed contents.
This function is an alias for jx_encode(), internally defined.


Parameters:
  1. $string
  2. String to be encoded
  3. $encoding
  4. Force encoding to a specific one