You are here

public static function Helper::fromUTF8 in Anti Spam by CleanTalk 8.4

Same name and namespace in other branches
  1. 9.1.x src/lib/Cleantalk/Common/Helper.php \Cleantalk\Common\Helper::fromUTF8()

* Function convert from UTF8 * *

Parameters

array|object|string $obj: * @param string $data_codepage * * @return mixed (array|object|string)

File

src/lib/Cleantalk/Common/Helper.php, line 1059

Class

Helper
CleanTalk Helper class. Compatible with any CMS.

Namespace

Cleantalk\Common

Code

public static function fromUTF8($obj, $data_codepage = null) {

  // Array || object
  if (is_array($obj) || is_object($obj)) {
    foreach ($obj as $key => &$val) {
      $val = self::fromUTF8($val, $data_codepage);
    }
    unset($key, $val);

    //String
  }
  else {
    if (preg_match('u', $obj) && function_exists('mb_convert_encoding') && $data_codepage !== null) {
      $obj = mb_convert_encoding($obj, $data_codepage, 'UTF-8');
    }
  }
  return $obj;
}