Converts shop to utf8.
357100
public function convertToUtf()
    {
        $dbHandler = $this->getDbHandler();

        $rs = $dbHandler->query(
            "SELECT oxvarname, oxvartype, DECODE( oxvarvalue, '{$this->getConfigKey()}') AS oxvarvalue
                       FROM oxconfig
                       WHERE oxvartype IN ('str', 'arr', 'aarr')"
        );

        while ( (false !== $rs) && ($aRow = $rs->fetch())) {
            if ($aRow['oxvartype'] == 'arr' || $aRow['oxvartype'] == 'aarr') {
                $aRow['oxvarvalue'] = unserialize($aRow['oxvarvalue']);
            }
            if (!empty($aRow['oxvarvalue']) && !is_int($aRow['oxvarvalue'])) {
                $this->updateConfigValue($aRow['oxid'], $this->stringToUtf($aRow['oxvarvalue']));
            }
        }

        // Change currencies value to same as after 4.6 setup because previous encoding break it.
        $shopId = 1;

        $query = "REPLACE INTO `oxconfig` (`OXID`, `OXSHOPID`, `OXMODULE`, `OXVARNAME`, `OXVARTYPE`, `OXVARVALUE`) VALUES
            ('3c4f033dfb8fd4fe692715dda19ecd28', $shopId, '', 'aCurrencies', 'arr', 0x4dbace2972e14bf2cbd3a9a45157004422e928891572b281961cdebd1e0bbafe8b2444b15f2c7b1cfcbe6e5982d87434c3b19629dacd7728776b54d7caeace68b4b05c6ddeff2df9ff89b467b14df4dcc966c504477a9eaeadd5bdfa5195a97f46768ba236d658379ae6d371bfd53acd9902de08a1fd1eeab18779b191f3e31c258a87b58b9778f5636de2fab154fc0a51a2ecc3a4867db070f85852217e9d5e9aa60507);";

        $dbHandler->query($query);
    }
612657
def to_unicode(value):
  
  if isinstance(value, str):
    return value.decode('utf-8')

  assert isinstance(value, unicode)
  return value
1195067
def json_unicode_to_utf8(data):
    """"""
    if isinstance(data, unicode):
        return data.encode('utf-8')
    elif isinstance(data, dict):
        newdict = {}
        for key in data:
            newdict[json_unicode_to_utf8(
                key)] = json_unicode_to_utf8(data[key])
        return newdict
    elif isinstance(data, list):
        return [json_unicode_to_utf8(elem) for elem in data]
    else:
        return data
1052979
function unicodeToUtf8() : SplString
    {

        $string = preg_replace_callback( '/\\\\u([0-9a-f]{4})/i', function( $matches ){
            return mb_convert_encoding( pack( "H*", $matches[1] ), "UTF-8", "UCS-2BE" );
        }, $this->__toString() );
        return $this->setString( $string );
    }
693800
def value_to_db(self, value):
        
        assert isinstance(value, six.integer_types)
        return str(value).encode("utf_8")
105854
private static int utf8Read3(int cu1, int cu2, int cu3) {
    if ((cu2 & 0xC0) != 0x80) {
      return INVALID;
    }
    if (cu1 == 0xE0 && cu2 < 0xA0) {
      // overlong
      return INVALID;
    }
    if ((cu3 & 0xC0) != 0x80) {
      return INVALID;
    }
    return (cu1 << 12) + (cu2 << 6) + cu3 - 0xE2080;
  }
1100585
private int utf8Position(int charPosition) {
    int pos = offset;
    for (int i = 0; i < charPosition; i++) {
      int byteValue = data[pos] & 0xff;
      if (byteValue < 0x80) {
        pos += 1;
      } else if (byteValue < 0xC2) {
        throw new UncheckedIOException("invalid UTF8", new CharacterCodingException());
      } else if (byteValue < 0xE0) {
        pos += 2;
      } else if (byteValue < 0xF0) {
        pos += 3;
      } else if (byteValue < 0xF8) {
        pos += 4;
      } else {
        throw new UncheckedIOException("invalid UTF8", new CharacterCodingException());
      }
    }
    return pos;
  }
1058237
def to_unicode(value):
    
    if isinstance(value, ffi.CData):
        return ffi.string(value).decode('utf-8')
    elif isinstance(value, binary_type):
        return value.decode('utf-8')
    elif isinstance(value, text_type):
        return value
    else:
        raise ValueError('Value must be text, bytes, or char[]')
903221
def convert_nonascii(self, lst):
        """"""
        for item in lst:
            if item.startswith('"') and item.endswith('"'):
                item = item[1:-1]
                yield item.encode('utf-8').decode('unicode-escape')
            else:
                yield item.encode('utf-8').decode('unicode-escape')
345996
public static function SanitizeUTF8($value)
    {
        if (self::getIsIconvEnabled()) {
            $value = @iconv('UTF-8', 'UTF-8', $value);
            return $value;
        }

        if (self::getIsMbstringEnabled()) {
            $value = mb_convert_encoding($value, 'UTF-8', 'UTF-8');
            return $value;
        }

        // else, no conversion
        return $value;
    }
1261091
public function utf8($value, array $options, $mode) {
        if ($mode === self::TO && $options['encode']) {
            return utf8_encode($value);
        }

        if ($mode === self::FROM && $options['decode']) {
            return utf8_decode($value);
        }

        return $value;
    }
814768
def read_utf8(fh, byteorder, dtype, count, offsetsize):
    """"""
    return fh.read(count).decode('utf-8')
78930
def euc_to_utf8(euchex):
    
    utf8 = euc_to_python(euchex).encode("utf-8")
    uf8 = utf8.decode('unicode_escape')

    uf8 = uf8.encode('latin1')

    uf8 = uf8.decode('euc-jp')
    return uf8
455976
def _strify(s):
    """"""
    if s is None:
        return None
    if isinstance(s, unicode):
        return s.encode("utf-8")
    return str(s)
548566
def to_utf8(path, output_path=None):
    
    if output_path is None:
        basename, ext = os.path.splitext(path)
        output_path = basename + "-UTF8Encode" + ext
    
    text = smartread(path)
    write(text, output_path)
292090
public static function utf8Encode($data) {
		if (is_string($data)) {
			return utf8_encode($data);

		} else if (is_array($data)) {
			foreach ($data as $key => $value) {
				$data[utf8_encode($key)] = self::utf8Encode($value);
			}

		} else if (is_object($data)) {
			foreach ($data as $key => $value) {
				$data->{$key} = self::utf8Encode($value);
			}
		}

		return $data;
	}
981497
def format_property(name, value):
    """"""
    result = b''
    utf8_name = utf8_bytes_string(name)

    result = b'property ' + utf8_name
    if value is not None:
        utf8_value = utf8_bytes_string(value)
        result += b' ' + ('%d' % len(utf8_value)).encode('ascii') + b' ' + utf8_value

    return result