本文整理汇总了PHP中utf8_to_ascii函数的典型用法代码示例。如果您正苦于以下问题:PHP utf8_to_ascii函数的具体用法?PHP utf8_to_ascii怎么用?PHP utf8_to_ascii使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了utf8_to_ascii函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: titleAlias
public function titleAlias($title)
{
$result = iaSanitize::tags($title);
$this->iaCore->factory('util');
iaUtil::loadUTF8Functions('ascii', 'validation', 'bad', 'utf8_to_ascii');
utf8_is_ascii($result) || ($result = utf8_to_ascii($result));
$result = preg_replace('#' . self::ALIAS_SUFFIX . '$#i', '', $result);
$result = iaSanitize::alias($result);
$result = substr($result, 0, 150);
// the DB scheme applies this limitation
$result .= self::ALIAS_SUFFIX;
return $result;
}
示例2: trans
/**
* Transcode a string
* @param $string string String to transcode
* @return string Result of transcoding
*/
function trans($string)
{
// detect existence of encoding conversion libraries
$mbstring = function_exists('mb_convert_encoding');
$iconv = function_exists('iconv');
// don't do work unless we have to
if (strtolower($this->fromEncoding) == strtolower($this->toEncoding)) {
return $string;
}
// 'HTML-ENTITIES' is not a valid encoding for iconv, so transcode manually
if ($this->toEncoding == 'HTML-ENTITIES' && !$mbstring) {
// NB: old PHP versions may have issues with htmlentities()
if (checkPhpVersion('5.2.3')) {
// don't double encode added in PHP 5.2.3
return htmlentities($string, ENT_COMPAT, $this->fromEncoding, false);
} else {
return htmlentities($string, ENT_COMPAT, $this->fromEncoding);
}
} elseif ($this->fromEncoding == 'HTML-ENTITIES' && !$mbstring) {
// NB: old PHP versions may have issues with html_entity_decode()
if (checkPhpVersion('4.3.0')) {
// multibyte character handling added in PHP 5.0.0
return html_entity_decode($string, ENT_COMPAT, $this->toEncoding);
} else {
// use built-in transcoding to UTF8
$string = String::html2utf($string);
// make another pass to target encoding
$this->fromEncoding = 'UTF-8';
return $this->trans($string);
}
// Special cases for transliteration ("down-sampling")
} elseif ($this->translit && $iconv) {
// use the iconv library to transliterate
return iconv($this->fromEncoding, $this->toEncoding . '//TRANSLIT', $string);
} elseif ($this->translit && $this->fromEncoding == "UTF-8" && $this->toEncoding == "ASCII") {
// use the utf2ascii library
require_once './lib/pkp/lib/phputf8/utf8_to_ascii.php';
return utf8_to_ascii($string);
} elseif ($mbstring) {
// use the mbstring library to transcode
return mb_convert_encoding($string, $this->toEncoding, $this->fromEncoding);
} elseif ($iconv) {
// use the iconv library to transcode
return iconv($this->fromEncoding, $this->toEncoding . '//IGNORE', $string);
} else {
// fail gracefully by returning the original string unchanged
return $string;
}
}
示例3: url
public function url($action, $data = array(), $generate = false)
{
$data['action'] = $action;
$data['alias'] = isset($data['artist_alias']) ? $data['artist_alias'] : $data['title_alias'];
if (!isset($this->patterns[$action])) {
$action = 'view';
}
if ($generate) {
$iaUtil = $iaCore->factory('core', 'util');
if (!defined('IA_NOUTF')) {
iaUtf8::loadUTF8Core();
iaUtf8::loadUTF8Util('ascii', 'validation', 'bad', 'utf8_to_ascii');
}
if (!utf8_is_ascii($data['alias'])) {
$data['alias'] = $iaCore->convertStr(utf8_to_ascii($data['alias']));
}
}
$url = iaDb::printf($this->patterns[$action], $data);
return self::get('url') . $url;
}
示例4: url
public function url($action, $data = array(), $generate = false)
{
$data['action'] = $action;
$data['alias'] = isset($data['genre_alias']) ? $data['genre_alias'] : $data['title_alias'];
if (!isset($this->patterns[$action])) {
$action = 'view';
}
if ($generate) {
iaCore::util();
if (!defined('IA_NOUTF')) {
iaUtf8::loadUTF8Core();
iaUtf8::loadUTF8Util('ascii', 'validation', 'bad', 'utf8_to_ascii');
}
if (!utf8_is_ascii($data['alias'])) {
$data['alias'] = $iaCore->convertStr(utf8_to_ascii($data['alias']));
}
}
$url = iaDb::printf($this->patterns[$action], $data);
return $this->iaCore->packagesData[self::PACKAGE_NAME]['url'] . $url;
}
示例5: toLatin1
function toLatin1($str, $enc = "")
{
if (!preg_match("/[^\\w\\.\\-\\@\\!\\#\$\\%\\^\\&\\*\\?\\[\\]\\{\\}\\.\\+\\/]/", $str)) {
return $str;
}
//echo "non latin char in name<BR>";
$orgNum = substr_count($str, "?");
// check utf
require_once dirname(__FILE__) . "/lib/utf8_to_ascii/utf8_to_ascii.php";
$newString = utf8_to_ascii($str);
$newNum = substr_count($newString, "?");
if ($newNum <= $orgNum) {
// no extra ? were added, this was a valid utf string
return $newString;
}
global $langEncodings, $nativeLanguage;
if ($enc == "") {
$enc = $langEncodings[$nativeLanguage];
}
require_once dirname(__FILE__) . "/lib/ConvertCharset/ConvertCharset.class.php";
$NewEncoding = new ConvertCharset();
$str_utf8 = $NewEncoding->Convert($str, $enc, "utf-8", $Entities);
return utf8_to_ascii($str_utf8);
}
示例6: utf8_to_ascii
$error = true;
$messages[] = iaLanguage::get('album_incorrect_account');
} else {
$data['member_id'] = $member_id;
}
} else {
$data['member_id'] = iaUsers::getIdentity()->id;
}
if (!defined('IA_NOUTF')) {
iaUtf8::loadUTF8Core();
iaUtf8::loadUTF8Util('ascii', 'validation', 'bad', 'utf8_to_ascii');
}
// validate title_alias
$data['title_alias'] = !empty($_POST['title_alias']) ? $_POST['title_alias'] : $_POST['title'];
if (!utf8_is_ascii($data['title_alias'])) {
$data['title_alias'] = utf8_to_ascii($data['title_alias']);
}
$data['title_alias'] = iaSanitize::convertStr($data['title_alias']);
// check for duplicate title_alias in case a new album is added or title_alias has been updated
if (!isset($item['title_alias']) || isset($item['title_alias']) && $data['title_alias'] != $item['title_alias']) {
if ($iaAlbum->existsAlias($data['title_alias'])) {
$error = true;
$messages[] = iaLanguage::get('album_already_exists');
}
}
if (!$error) {
$iaCore->startHook("phpAdminBeforeAlbumSubmit");
if (!empty($_POST['artist'])) {
$artist_info = $iaArtist->getArtistByTitle($_POST['artist']);
$data['id_artist'] = $artist_info['id'];
$data['artist_alias'] = $artist_info['title_alias'];
示例7: foreach
</div><!-- /header -->
<div class="content">
<ul data-role="listview" data-split-icon="gear" data-split-theme="a" data-inset="true" class="list-view">
<?php
if (!empty($app)) {
foreach ($app as $key => $value) {
$temp = json_decode($value['download_url'], TRUE);
unset($temp['plist']);
$k = array_keys($temp);
?>
<li>
<a href="<?php
echo base_url('ung-dung/' . utf8_to_ascii($value['name']) . '-' . $value['id_game_app']);
?>
.html">
<img src="<?php
echo base_url($value['icon']);
?>
" class="img-list-game-app"/>
<h2><?php
echo $value['name'];
?>
</h2>
<p id="info-game"><?php
echo $value['count_download'];
?>
tải | <?php
echo $value['size'];
示例8: transliterate
/**
* Transliterates (strips accents) text.
*
* For example. ë becomes e.
*
* @static
* @param $str The input string.
* @return string The transliterated string.
*/
public static function transliterate($string)
{
return utf8_to_ascii($string);
}
示例9: addinfo
public function addinfo()
{
$this->load->library('form_validation');
$response['code'] = -1;
$response['redirect'] = '/backend/wap_info/index';
$response['message']['title'] = '';
// $response['message']['type'] = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$arrParam = $this->input->post(NULL, TRUE);
$Id = @$arrParam['id'];
$this->form_validation->set_rules('title', 'title', 'callback_xss_check|trim|required');
$this->form_validation->set_message('required', 'Không được rỗng');
if ($this->form_validation->run() == TRUE) {
// die(json_encode($arrParam));
$Params = array();
$Params['title'] = $this->security->xss_clean($arrParam['title']);
$Params['alias'] = utf8_to_ascii($Params['title']);
$Params['content'] = $arrParam['content'];
if (empty($Id) === TRUE) {
$this->load->library('session');
$this->m_backend->jqxInsert('info_wap', $Params);
} else {
$this->m_backend->jqxUpdate('info_wap', 'id', $Id, $Params);
}
$response['code'] = 0;
} else {
$badchars = array('<p>', '</p>');
$response['message']['title'] = trim(str_replace($badchars, '', form_error('title')));
$response['message']['content'] = trim(str_replace($badchars, '', form_error('type')));
$response['code'] = 1;
}
}
end:
echo json_encode($response);
exit;
}
示例10: foreach
<!------------------------------------------------------------->
<div class="content name-block">
<span>VIDEOS</span>
</div>
<div class="content">
<ul data-role="listview" data-split-icon="gear" data-split-theme="a" data-inset="true"
class="list-view list-view-news-video">
<?php
if (!empty($videos)) {
foreach ($videos as $key => $value) {
?>
<li>
<div class="over-play"></div>
<a href="<?php
echo base_url('videos/' . utf8_to_ascii($value['name']) . '-' . $value['id_news_video']);
?>
.html">
<img src="<?php
echo base_url($value['image']);
?>
"/>
<h2><?php
echo $value['name'];
?>
</h2>
<p id="descript-game"><?php
echo limit_text($value['description'], 20);
示例11: ascii_link
/**
* Tạo link không dấu để SEO
* @author Nguyen Xuan Hung
* @data 02.03.2011
*/
function ascii_link($title = '', $char = '-')
{
$name = strtolower(utf8_to_ascii($title));
$name = preg_replace("/[^a-z0-9]/i", ' ', $name);
// a-z - . space
$name = preg_replace("/\\s{2,}/i", ' ', trim($name));
// Replace 2 or more space = 1 space
$name = str_replace(' ', $char, $name);
return $name;
}
示例12: alias
/**
* Converts text to well-formed URL, replaces all non alpha-numeric / underscore symbols to separator
*
* @param string $string text to be converted
* @param string $separator separator symbol used for the conversion
*
* @return string
*/
public static function alias($string, $separator = '-')
{
iaCore::instance()->factory('util')->loadUTF8Functions('ascii', 'validation', 'bad', 'utf8_to_ascii');
$string = html_entity_decode($string);
$string = str_replace(array('&', "'"), array('and', ''), $string);
$urlEncoded = false;
if (!utf8_is_ascii($string)) {
if (iaCore::instance()->get('alias_urlencode', false)) {
$string = preg_replace('#[^0-9\\p{L}]+#ui', $separator, $string);
$urlEncoded = true;
} else {
$string = utf8_to_ascii($string);
}
}
$string = $urlEncoded ? $string : preg_replace('#[^a-z0-9_]+#i', $separator, $string);
$string = trim($string, $separator);
return $string;
}
示例13: _getJsonUrl
private function _getJsonUrl(array $params)
{
iaUtil::loadUTF8Functions('ascii', 'utf8_to_ascii');
$name = $params['name'];
$name = utf8_is_ascii($name) ? $name : utf8_to_ascii($name);
$name = preg_replace('#[^a-z0-9-_]#iu', '', $name);
$url = $params['url'];
$url = utf8_is_ascii($url) ? $url : utf8_to_ascii($url);
$url = preg_replace('#[^a-z0-9-_]#iu', '', $url);
$url = $url ? $url : $name;
if (is_numeric($params['parent']) && $params['parent']) {
$parentPage = $this->getById($params['parent']);
$parentAlias = empty($parentPage['alias']) ? $parentPage['name'] . IA_URL_DELIMITER : $parentPage['alias'];
$url = $parentAlias . (IA_URL_DELIMITER == substr($parentAlias, -1, 1) ? '' : IA_URL_DELIMITER) . $url;
}
$url .= $params['ext'];
$exists = $this->_iaDb->exists('`alias` = :url AND `name` != :name', array('url' => $url, 'name' => $name));
$url = IA_URL . $url;
return array('url' => $url, 'exists' => $exists);
}
示例14: upp_mangle_filename
function upp_mangle_filename($file_name)
{
/* remove internal dots (cosmetical, it would be done by WP, but we need to display it :)*/
$ext = upp_findexts($file_name);
$file_name = str_replace("." . $ext, "", $file_name);
$file_name = str_replace(".", "", $file_name);
// initial cleaning
$file_name = str_replace("(", "", $file_name);
$file_name = str_replace(")", "", $file_name);
$file_name = str_replace("'", "", $file_name);
$file_name = str_replace('"', "", $file_name);
$file_name = str_replace(',', "", $file_name);
// some language-based prefilter. props denis.
$de_from = array('ä', 'ö', 'ü', 'ß', 'Ä', 'Ö', 'Ü');
$de_to = array('ae', 'oe', 'ue', 'ss', 'Ae', 'Oe', 'Ue');
$file_name = str_replace($de_from, $de_to, $file_name);
$utf8ornot = get_option('uploadplus_utf8toascii');
if ($utf8ornot[0] == 1) {
$file_name = utf8_to_ascii($file_name);
}
$file_name = $file_name . "." . $ext;
$lettercase = get_option('uploadplus_case');
switch ($lettercase[0]) {
case "1":
$file_name = utf8_strtolower($file_name);
break;
case "2":
$file_name = utf8_strtoupper($file_name);
break;
}
$y = get_option('uploadplus_cleanlevel');
switch ($y[0]) {
case "1":
$file_name = ereg_replace("[^A-Za-z0-9._]", "-", $file_name);
$file_name = utf8_ireplace("_", "-", $file_name);
$file_name = utf8_ireplace(" ", "-", $file_name);
$file_name = utf8_ireplace("%20", "-", $file_name);
break;
case "2":
$file_name = ereg_replace("[^A-Za-z0-9._]", "", $file_name);
$file_name = utf8_ireplace("_", "", $file_name);
$file_name = utf8_ireplace("-", "", $file_name);
$file_name = utf8_ireplace("%20", "", $file_name);
break;
case "3":
$file_name = ereg_replace("[^A-Za-z0-9._]", "_", $file_name);
$file_name = utf8_ireplace("-", "_", $file_name);
$file_name = utf8_ireplace(" ", "_", $file_name);
$file_name = utf8_ireplace("%20", "_", $file_name);
break;
}
$sep = $y[0] == '1' ? "-" : "";
if (!$sep) {
$sep = $y[0] == '3' ? "_" : "";
}
$standard = get_option('uploadplus_prefix');
switch ($standard) {
case "0":
$file_name = date('d') . $sep . $file_name;
break;
case "1":
$file_name = date('md') . $sep . $file_name;
break;
case "2":
$file_name = date('ymd') . $sep . $file_name;
break;
case "3":
$file_name = date('Ymd') . $sep . $file_name;
break;
case "4":
$file_name = date('YmdHi') . $sep . $file_name;
break;
case "5":
$file_name = date('YmdHis') . $sep . $file_name;
break;
case "6":
$file_name = date('U') . $sep . $file_name;
break;
case "7":
$file_name = mt_rand() . $sep . $file_name;
break;
case "8":
$file_name = md5(mt_rand()) . $sep . $file_name;
break;
case "9":
$file_name = str_replace(array(".", "_", "-", " "), $sep, utf8_to_ascii(get_bloginfo('name'))) . $sep . $file_name;
break;
case "A":
$file_name = str_replace(array(".", "_", "-", " "), "", utf8_to_ascii(get_bloginfo('name'))) . $sep . $file_name;
break;
}
return $file_name;
}
示例15: action_search
public function action_search()
{
$params = $this->input->get(NULL, TRUE);
$data = $this->m_wap->search($params['data']);
$num_row = $this->m_wap->get_num_row('game_app', array('type' => 'app', 'status' => 'active', 'cate' => $params['cat']));
if (!empty($data)) {
foreach ($data as $key => $value) {
$temp = json_decode($value['download_url'], TRUE);
unset($temp['plist']);
$k = array_keys($temp);
$class = 'a.click-download-game-' . $value['id_game_app'];
$sub = 'ung-dung';
if ($value['type'] == 'game') {
$sub = 'game';
}
$result .= '
<li class="ui-li-has-alt ui-li-has-thumb">
<a href="' . base_url($sub . '/' . utf8_to_ascii($value['name']) . '-' . $value['id_game_app'] . '.html') . '" class="ui-btn">
<img src="' . base_url($value["icon"]) . '" />
<h2>' . $value['name'] . '</h2>
<p id="info-game"> ' . $value["count_download"] . 'tải | ' . $value['size'] . ' kb</p>
<p id="descript-game">' . limit_text($value["description"], 20) . '</p>
</a>
<a href="#purchase-app" data-rel="popup" onclick="abc' . $value['id_game_app'] . '();" data-position-to="window" data-transition="pop" aria-haspopup="true" aria-owns="purchase" aria-expanded="false" class="ui-btn ui-btn-icon-notext ui-icon-gear ui-btn-a" title=""></a>
<div class="free-download">FREE</div>
</li>
<script>
function abc' . $value['id_game_app'] . '(){
var _json = \'' . json_encode($k) . '\';
var _id_game = \'' . $value['id_game_app'] . '\'
var _obj = JSON.parse(_json);
var _html = "";
if (platform == "pc") {
for (var key in _obj) {
_html += \'<a target="_blank" href="' . base_url() . 'tai-game?id=\' + _id_game + \'&platform=\' + _obj[key] + \'" data-ajax="false"><button class="ui-bnt ui-btn ui-shadow ui-corner-all" style="text-transform: uppercase">\' + _obj[key] + \'</button></a>\';
$(\'.bnt-download-game\').html(_html);
}
}else{
$(\'#purchase-app\').remove();
for (var key in _obj) {
if (_obj[key] == \'' . $_SESSION['platform'] . '\') {
_html = \'' . base_url() . 'tai-game?id=\' + _id_game + \'&platform=\' + _obj[key];
if (confirm(\'Bạn có tải ứng dụng?\')) {
window.open(_html);
}
}
}
}
}
</script>
';
}
}
$array_result = array('isLoadmore' => check_last_page($offset, $num_row), 'html' => $result, 'page' => $params['page'] + 1);
die(json_encode($array_result));
}