本文整理汇总了PHP中utf8_deaccent函数的典型用法代码示例。如果您正苦于以下问题:PHP utf8_deaccent函数的具体用法?PHP utf8_deaccent怎么用?PHP utf8_deaccent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了utf8_deaccent函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderXml
public function renderXml()
{
$nameSuffix = str_replace(' ', '-', utf8_romanize(utf8_deaccent(ucfirst($this->_params['name']))));
XenForo_Application::autoload('Zend_Debug');
$this->setDownloadFileName('BBM_BbCode_' . $nameSuffix . '.xml');
return $this->_params['xml']->saveXml();
}
示例2: add
function add()
{
$a = $this->get_macros();
$macros = $_REQUEST['macro'];
$words = $_REQUEST['word'];
foreach ($macros as $key => $value) {
if (isset($value) && trim($value)) {
if (isset($words[$key]) && trim($words[$key])) {
$value = utf8_deaccent($value);
$a[$value] = htmlspecialchars($words[$key], ENT_NOQUOTES, 'UTF-8');
}
}
}
io_saveFile(MACROS_FILE, serialize($a));
return $a;
}
示例3: cleanID
function cleanID($raw_id)
{
$sepchar = "_";
$sepcharpat = '#\\' . $sepchar . '+#';
$id = trim((string) $raw_id);
$id = utf8_strtolower($id);
//alternative namespace seperator
$id = strtr($id, ';', ':');
$id = strtr($id, '/', $sepchar);
$id = utf8_romanize($id);
$id = utf8_deaccent($id, -1);
//remove specials
$id = utf8_stripspecials($id, $sepchar, '\\*');
$id = utf8_strip($id);
$id = preg_replace($sepcharpat, $sepchar, $id);
$id = preg_replace('#:+#', ':', $id);
$id = preg_replace('#:[:\\._\\-]+#', ':', $id);
return $id;
}
示例4: mail_encode_address
/**
* Encodes an email address header
*
* Unicode characters will be deaccented and encoded
* quoted_printable for headers.
* Addresses may not contain Non-ASCII data!
*
* Example:
* mail_encode_address("föö <foo@bar.com>, me@somewhere.com","TBcc");
*
* @param string $string Multiple adresses separated by commas
* @param string $header Name of the header (To,Bcc,Cc,...)
* @param boolean $names Allow named Recipients?
*/
function mail_encode_address($string, $header = '', $names = true)
{
$headers = '';
$parts = split(',', $string);
foreach ($parts as $part) {
$part = trim($part);
// parse address
if (preg_match('#(.*?)<(.*?)>#', $part, $matches)) {
$text = trim($matches[1]);
$addr = $matches[2];
} else {
$addr = $part;
}
// skip empty ones
if (empty($addr)) {
continue;
}
// FIXME: is there a way to encode the localpart of a emailaddress?
if (!utf8_isASCII($addr)) {
msg(htmlspecialchars("E-Mail address <{$addr}> is not ASCII"), -1);
continue;
}
if (!mail_isvalid($addr)) {
msg(htmlspecialchars("E-Mail address <{$addr}> is not valid"), -1);
continue;
}
// text was given
if (!empty($text) && $names) {
// add address quotes
$addr = "<{$addr}>";
if (defined('MAILHEADER_ASCIIONLY')) {
$text = utf8_deaccent($text);
$text = utf8_strip($text);
}
if (!utf8_isASCII($text)) {
$text = '=?UTF-8?Q?' . mail_quotedprintable_encode($text, 0) . '?=';
}
} else {
$text = '';
}
// add to header comma seperated and in new line to avoid too long headers
if ($headers != '') {
$headers .= ',' . MAILHEADER_EOL . ' ';
}
$headers .= $text . ' ' . $addr;
}
if (empty($headers)) {
return null;
}
//if headername was given add it and close correctly
if ($header) {
$headers = $header . ': ' . $headers . MAILHEADER_EOL;
}
return $headers;
}
示例5: array
<?php
if (!empty($_GET['anywhere']) && $_GET['searchtype'] == 'metadata') {
$anywhere_array = array($_GET['anywhere']);
if ($_GET['anywhere_separator'] == 'AND' || $_GET['anywhere_separator'] == 'OR') {
$anywhere_array = explode(' ', $_GET['anywhere']);
}
while ($anywhere = each($anywhere_array)) {
$like_query_esc = str_replace("\\", "\\\\", $anywhere[1]);
$like_query_esc = str_replace("%", "\\%", $like_query_esc);
$like_query_esc = str_replace("_", "\\_", $like_query_esc);
$like_query_esc = str_replace("<*>", "%", $like_query_esc);
$like_query_esc = str_replace("<?>", "_", $like_query_esc);
$author_like_query = $dbHandle->quote("%L:\"{$like_query_esc}%");
$like_query = $dbHandle->quote("%{$like_query_esc}%");
$translation = utf8_deaccent($like_query_esc);
if ($translation != $like_query_esc) {
$author_like_query_translated = $dbHandle->quote("%L:\"{$translation}%");
$like_query_translated = $dbHandle->quote("%{$translation}%");
$like_sql = "authors LIKE {$author_like_query} ESCAPE '\\' OR" . " editor LIKE {$author_like_query} ESCAPE '\\' OR" . " journal LIKE {$like_query} ESCAPE '\\' OR" . " secondary_title LIKE {$like_query} ESCAPE '\\' OR" . " tertiary_title LIKE {$like_query} ESCAPE '\\' OR" . " affiliation LIKE {$like_query} ESCAPE '\\' OR" . " title LIKE {$like_query} ESCAPE '\\' OR" . " abstract LIKE {$like_query} ESCAPE '\\' OR" . " year LIKE {$like_query} ESCAPE '\\' OR" . " id=" . intval($anywhere[1]) . " OR" . " keywords LIKE {$like_query} ESCAPE '\\' OR" . " authors_ascii LIKE {$author_like_query_translated} ESCAPE '\\' OR" . " title_ascii LIKE {$like_query_translated} ESCAPE '\\' OR" . " abstract_ascii LIKE {$like_query_translated} ESCAPE '\\'";
} else {
$like_sql = "authors_ascii LIKE {$author_like_query} ESCAPE '\\' OR" . " editor LIKE {$author_like_query} ESCAPE '\\' OR" . " journal LIKE {$like_query} ESCAPE '\\' OR" . " secondary_title LIKE {$like_query} ESCAPE '\\' OR" . " tertiary_title LIKE {$like_query} ESCAPE '\\' OR" . " affiliation LIKE {$like_query} ESCAPE '\\' OR" . " title_ascii LIKE {$like_query} ESCAPE '\\' OR" . " abstract_ascii LIKE {$like_query} ESCAPE '\\' OR" . " year LIKE {$like_query} ESCAPE '\\' OR" . " id=" . intval($anywhere[1]) . " OR" . " keywords LIKE {$like_query} ESCAPE '\\'";
}
$anywhere_regexp[] = '(' . $like_sql . ')';
}
if ($_GET['anywhere_separator'] == 'AND') {
$search_string = join(' AND ', $anywhere_regexp);
}
if ($_GET['anywhere_separator'] == 'OR') {
$search_string = join(' OR ', $anywhere_regexp);
}
示例6: _verifyUsername
/**
* Verification callback to check that a username is valid
*
* @param string Username
*
* @return bool
*/
protected function _verifyUsername(&$username)
{
if ($this->isUpdate() && $username === $this->getExisting('username')) {
return true;
// unchanged, always pass
}
// standardize white space in names
$username = preg_replace('/\\s+/u', ' ', $username);
try {
// if this matches, then \v isn't known (appears to be PCRE < 7.2) so don't strip
if (!preg_match('/\\v/', 'v')) {
$newName = preg_replace('/\\v+/u', ' ', $username);
if (is_string($newName)) {
$username = $newName;
}
}
} catch (Exception $e) {
}
$username = trim($username);
$usernameLength = utf8_strlen($username);
$minLength = $this->getOption(self::OPTION_USERNAME_LENGTH_MIN);
$maxLength = $this->getOption(self::OPTION_USERNAME_LENGTH_MAX);
if (!$this->getOption(self::OPTION_ADMIN_EDIT)) {
if ($minLength > 0 && $usernameLength < $minLength) {
$this->error(new XenForo_Phrase('please_enter_name_that_is_at_least_x_characters_long', array('count' => $minLength)), 'username');
return false;
}
if ($maxLength > 0 && $usernameLength > $maxLength) {
$this->error(new XenForo_Phrase('please_enter_name_that_is_at_most_x_characters_long', array('count' => $maxLength)), 'username');
return false;
}
$disallowedNames = $this->getOption(self::OPTION_USERNAME_DISALLOWED_NAMES);
if ($disallowedNames) {
foreach ($disallowedNames as $name) {
$name = trim($name);
if ($name === '') {
continue;
}
if (stripos($username, $name) !== false) {
$this->error(new XenForo_Phrase('please_enter_another_name_disallowed_words'), 'username');
return false;
}
}
}
$matchRegex = $this->getOption(self::OPTION_USERNAME_REGEX);
if ($matchRegex) {
$matchRegex = str_replace('#', '\\#', $matchRegex);
// escape delim only
if (!preg_match('#' . $matchRegex . '#i', $username)) {
$this->error(new XenForo_Phrase('please_enter_another_name_required_format'), 'username');
return false;
}
}
$censoredUserName = XenForo_Helper_String::censorString($username);
if ($censoredUserName !== $username) {
$this->error(new XenForo_Phrase('please_enter_name_that_does_not_contain_any_censored_words'), 'username');
return false;
}
}
// ignore check if unicode properties aren't compiled
try {
if (@preg_match("/\\p{C}/u", $username)) {
$this->error(new XenForo_Phrase('please_enter_name_without_using_control_characters'), 'username');
return false;
}
} catch (Exception $e) {
}
if (strpos($username, ',') !== false) {
$this->error(new XenForo_Phrase('please_enter_name_that_does_not_contain_comma'), 'username');
return false;
}
if (XenForo_Helper_Email::isEmailValid($username)) {
$this->error(new XenForo_Phrase('please_enter_name_that_does_not_resemble_an_email_address'), 'username');
return false;
}
$existingUser = $this->_getUserModel()->getUserByName($username);
if ($existingUser && $existingUser['user_id'] != $this->get('user_id')) {
$this->error(new XenForo_Phrase('usernames_must_be_unique'), 'username');
return false;
}
// compare against romanized name to help reduce confusable issues
$romanized = utf8_deaccent(utf8_romanize($username));
if ($romanized != $username) {
$existingUser = $this->_getUserModel()->getUserByName($romanized);
if ($existingUser && $existingUser['user_id'] != $this->get('user_id')) {
$this->error(new XenForo_Phrase('usernames_must_be_unique'), 'username');
return false;
}
}
return true;
}
示例7: cleanID
/**
* Remove unwanted chars from ID
*
* Cleans a given ID to only use allowed characters. Accented characters are
* converted to unaccented ones
*
* @author Andreas Gohr <andi@splitbrain.org>
* @param string $raw_id The pageid to clean
* @param boolean $ascii Force ASCII
* @param boolean $media Allow leading or trailing _ for media files
*/
function cleanID($raw_id, $ascii = false, $media = false)
{
global $conf;
static $sepcharpat = null;
global $cache_cleanid;
$cache =& $cache_cleanid;
// check if it's already in the memory cache
if (isset($cache[(string) $raw_id])) {
return $cache[(string) $raw_id];
}
$sepchar = $conf['sepchar'];
if ($sepcharpat == null) {
// build string only once to save clock cycles
$sepcharpat = '#\\' . $sepchar . '+#';
}
$id = trim((string) $raw_id);
$id = utf8_strtolower($id);
//alternative namespace seperator
$id = strtr($id, ';', ':');
if ($conf['useslash']) {
$id = strtr($id, '/', ':');
} else {
$id = strtr($id, '/', $sepchar);
}
if ($conf['deaccent'] == 2 || $ascii) {
$id = utf8_romanize($id);
}
if ($conf['deaccent'] || $ascii) {
$id = utf8_deaccent($id, -1);
}
//remove specials
$id = utf8_stripspecials($id, $sepchar, '\\*');
if ($ascii) {
$id = utf8_strip($id);
}
//clean up
$id = preg_replace($sepcharpat, $sepchar, $id);
$id = preg_replace('#:+#', ':', $id);
$id = $media ? trim($id, ':.-') : trim($id, ':._-');
$id = preg_replace('#:[:\\._\\-]+#', ':', $id);
$cache[(string) $raw_id] = $id;
return $id;
}
示例8: cleanHeaders
/**
* Cleanup and encode the headers array
*/
protected function cleanHeaders()
{
global $conf;
// clean up addresses
if (empty($this->headers['From'])) {
$this->from($conf['mailfrom']);
}
$addrs = array('To', 'From', 'Cc', 'Bcc', 'Reply-To', 'Sender');
foreach ($addrs as $addr) {
if (isset($this->headers[$addr])) {
$this->headers[$addr] = $this->cleanAddress($this->headers[$addr]);
}
}
if (isset($this->headers['Subject'])) {
// add prefix to subject
if (empty($conf['mailprefix'])) {
if (utf8_strlen($conf['title']) < 20) {
$prefix = '[' . $conf['title'] . ']';
} else {
$prefix = '[' . utf8_substr($conf['title'], 0, 20) . '...]';
}
} else {
$prefix = '[' . $conf['mailprefix'] . ']';
}
$len = strlen($prefix);
if (substr($this->headers['Subject'], 0, $len) != $prefix) {
$this->headers['Subject'] = $prefix . ' ' . $this->headers['Subject'];
}
// encode subject
if (defined('MAILHEADER_ASCIIONLY')) {
$this->headers['Subject'] = utf8_deaccent($this->headers['Subject']);
$this->headers['Subject'] = utf8_strip($this->headers['Subject']);
}
if (!utf8_isASCII($this->headers['Subject'])) {
$this->headers['Subject'] = '=?UTF-8?B?' . base64_encode($this->headers['Subject']) . '?=';
}
}
}
示例9: _getUrlVersionOfTag
protected function _getUrlVersionOfTag($tag)
{
$db = $this->_getDb();
$urlVersion = preg_replace('/[^a-zA-Z0-9_ -]/', '', utf8_romanize(utf8_deaccent($tag)));
$urlVersion = preg_replace('/[ -]+/', '-', $urlVersion);
if (!strlen($urlVersion)) {
$urlVersion = 1 + intval($db->fetchOne("\r\n\t\t\t\tSELECT MAX(tag_id)\r\n\t\t\t\tFROM xf_tag\r\n\t\t\t"));
} else {
$existing = $db->fetchRow("\r\n\t\t\t\tSELECT *\r\n\t\t\t\tFROM xf_tag\r\n\t\t\t\tWHERE tag_url = ?\r\n\t\t\t\t\tOR (tag_url LIKE ? AND tag_url REGEXP ?)\r\n\t\t\t\tORDER BY tag_id DESC\r\n\t\t\t\tLIMIT 1\r\n\t\t\t", array($urlVersion, "{$urlVersion}-%", "^{$urlVersion}-[0-9]+\$"));
if ($existing) {
$counter = 1;
if ($existing['tag_url'] != $urlVersion && preg_match('/-(\\d+)$/', $existing['tag_url'], $match)) {
$counter = $match[1];
}
$testExists = true;
while ($testExists) {
$counter++;
$testExists = $db->fetchOne("\r\n\t\t\t\t\t\tSELECT tag_id\r\n\t\t\t\t\t\tFROM xf_tag\r\n\t\t\t\t\t\tWHERE tag_url = ?\r\n\t\t\t\t\t", "{$urlVersion}-{$counter}");
}
$urlVersion .= "-{$counter}";
}
}
return $urlVersion;
}
示例10: str_pad
$stmt->bindParam(':authors_ascii', $authors_ascii, PDO::PARAM_STR);
$stmt->bindParam(':title_ascii', $title_ascii, PDO::PARAM_STR);
$stmt->bindParam(':abstract_ascii', $abstract_ascii, PDO::PARAM_STR);
$stmt->bindParam(':added_by', $userID, PDO::PARAM_INT);
$dbHandle->exec("BEGIN IMMEDIATE TRANSACTION");
$stmt->execute();
$stmt = null;
$id = $dbHandle->lastInsertId();
$new_file = str_pad($id, 5, "0", STR_PAD_LEFT) . '.pdf';
// Save citation key.
$stmt6 = $dbHandle->prepare("UPDATE library SET bibtex=:bibtex WHERE id=:id");
$stmt6->bindParam(':bibtex', $bibtex, PDO::PARAM_STR);
$stmt6->bindParam(':id', $id, PDO::PARAM_INT);
$bibtex_author = 'unknown';
if (!empty($last_name[0])) {
$bibtex_author = utf8_deaccent($last_name[0]);
}
empty($year) ? $bibtex_year = '0000' : ($bibtex_year = substr($year, 0, 4));
$bibtex = $bibtex_author . '-' . $bibtex_year . '-ID' . $id;
$insert = $stmt6->execute();
$insert = null;
if (isset($_GET['shelf']) && !empty($userID)) {
$user_query = $dbHandle->quote($userID);
$file_query = $dbHandle->quote($id);
$dbHandle->exec("INSERT OR IGNORE INTO shelves (userID,fileID) VALUES ({$user_query},{$file_query})");
}
if (isset($_GET['project']) && !empty($_GET['projectID'])) {
$dbHandle->exec("INSERT OR IGNORE INTO projectsfiles (projectID,fileID) VALUES (" . intval($_GET['projectID']) . "," . intval($id) . ")");
}
####### record new category into categories, if not exists #########
if (!empty($_GET['category2'])) {
示例11: htmlspecialchars
print "<br><u>External IDs:</u> " . htmlspecialchars(implode(", ", $uids));
print '<br><u>DOI:</u> <span id="file-doi">' . htmlspecialchars($paper['doi']) . '</span>';
if (!empty($paper['bibtex'])) {
print '<br><u>BibTex:</u> <input type="text" class="bibtex" value="' . htmlspecialchars($paper['bibtex']) . '" style="outline:none;width:200px" readonly>';
} else {
$bibtex_author = substr($paper['authors'], 3);
$bibtex_author = substr($bibtex_author, 0, strpos($bibtex_author, '"'));
if (empty($bibtex_author)) {
$bibtex_author = 'unknown';
}
$bibtex_year = '0000';
$bibtex_year_array = explode('-', $paper['year']);
if (!empty($bibtex_year_array[0])) {
$bibtex_year = $bibtex_year_array[0];
}
$bibtex_key = utf8_deaccent($bibtex_author) . '-' . $bibtex_year . '-ID' . $paper['id'];
print '<br><u>BibTex:</u> <input type="text" class="bibtex" value="' . $bibtex_key . '" style="outline:none;width:200px" readonly>';
}
$editor_string = '';
if (!empty($paper['editor'])) {
$array = explode(';', $paper['editor']);
$array = array_filter($array);
if (!empty($array)) {
foreach ($array as $editor) {
$array2 = explode(',', $editor);
$last = trim($array2[0]);
$last = substr($array2[0], 3, -1);
$first = trim($array2[1]);
$first = substr($array2[1], 3, -1);
$new_editor[] = $last . ', ' . $first;
}
示例12: getTitleForUrl
/**
* Gets version of a title that is valid in a URL. Invalid elements are stripped
* or replaced with '-'. It may not be possible to reverse a URL'd title to the
* original title.
*
* @param string $title
* @param boolean $romanize If true, non-latin strings are romanized
*
* @return string
*/
public static function getTitleForUrl($title, $romanize = false)
{
$title = strval($title);
$lookup = $title . ($romanize ? '|r' : '');
if (isset(self::$_titleCache[$lookup])) {
return self::$_titleCache[$lookup];
}
if ($romanize) {
$title = utf8_romanize(utf8_deaccent($title));
}
$aPattern = array("a" => "á|à|ạ|ả|ã|ă|ắ|ằ|ặ|ẳ|ẵ|â|ấ|ầ|ậ|ẩ|ẫ|Á|À|Ạ|Ả|Ã|Ă|Ắ|Ằ|Ặ|Ẳ|Ẵ|Â|Ấ|Ầ|Ậ|Ẩ|Ẫ", "o" => "ó|ò|ọ|ỏ|õ|ô|ố|ồ|ộ|ổ|ỗ|ơ|ớ|ờ|ợ|ở|ỡ|Ó|Ò|Ọ|Ỏ|Õ|Ô|Ố|Ồ|Ộ|Ổ|Ỗ|Ơ|Ớ|Ờ|Ợ|Ở|Ỡ", "e" => "é|è|ẹ|ẻ|ẽ|ê|ế|ề|ệ|ể|ễ|É|È|Ẹ|Ẻ|Ẽ|Ê|Ế|Ề|Ệ|Ể|Ễ", "u" => "ú|ù|ụ|ủ|ũ|ư|ứ|ừ|ự|ử|ữ|Ú|Ù|Ụ|Ủ|Ũ|Ư|Ứ|Ừ|Ự|Ử|Ữ", "i" => "í|ì|ị|ỉ|ĩ|Í|Ì|Ị|Ỉ|Ĩ", "y" => "ý|ỳ|ỵ|ỷ|ỹ|Ý|Ỳ|Ỵ|Ỷ|Ỹ", "d" => "đ|Đ");
while (list($key, $value) = each($aPattern)) {
$title = @ereg_replace($value, $key, $title);
}
$title = strtr($title, '`!"$%^&*()-+={}[]<>;:@#~,./?|' . "\r\n\t\\", ' ' . ' ');
$title = strtr($title, array('"' => '', "'" => ''));
if ($romanize) {
$title = preg_replace('/[^a-zA-Z0-9_ -]/', '', $title);
}
$title = preg_replace('/[ ]+/', '-', trim($title));
$title = strtr($title, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz');
self::$_titleCache[$lookup] = $title;
return $title;
}
示例13: utf8_deaccent
function utf8_deaccent($string, $case = 0)
{
return utf8_deaccent($string, $case);
}
示例14: renderXml
public function renderXml()
{
$title = str_replace(' ', '-', utf8_romanize(utf8_deaccent($this->_params['style']['title'])));
$this->setDownloadFileName('style-' . $title . '.xml');
return $this->_params['xml']->saveXml();
}
示例15: reset
}
}
reset($add_item);
}
if (isset($add_item['id'])) {
$id_author = substr($item['authors'], 3);
$id_author = substr($id_author, 0, strpos($id_author, '"'));
if (empty($id_author)) {
$id_author = 'unknown';
}
$id_year_array = explode('-', $item['year']);
$id_year = '0000';
if (!empty($id_year_array[0])) {
$id_year = $id_year_array[0];
}
$add_item['id'] = utf8_deaccent($id_author) . '-' . $id_year . '-ID' . $item['id'];
if ($_GET['format'] == 'BibTex' && !empty($item['bibtex'])) {
$add_item['id'] = $item['bibtex'];
}
$add_item['id'] = str_replace(' ', '', $add_item['id']);
}
if ($_GET['format'] == 'list') {
$new_authors = array();
$array = explode(';', $item['authors']);
$array = array_filter($array);
if (!empty($array)) {
foreach ($array as $author) {
$array2 = explode(',', $author);
$last = trim($array2[0]);
$last = substr($array2[0], 3, -1);
$first = trim($array2[1]);