本文整理汇总了PHP中utf8_strip函数的典型用法代码示例。如果您正苦于以下问题:PHP utf8_strip函数的具体用法?PHP utf8_strip怎么用?PHP utf8_strip使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了utf8_strip函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: 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;
}
开发者ID:ryanmuller,项目名称:folders2web,代码行数:19,代码来源:clean_id.php
示例2: 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öö <[email protected]>, [email protected]","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 = explode(',', $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)) {
// put the quotes outside as in =?UTF-8?Q?"Elan Ruusam=C3=A4e"?= vs "=?UTF-8?Q?Elan Ruusam=C3=A4e?="
if (preg_match('/^"(.+)"$/', $text, $matches)) {
$text = '"=?UTF-8?Q?' . mail_quotedprintable_encode($matches[1], 0) . '?="';
} else {
$text = '=?UTF-8?Q?' . mail_quotedprintable_encode($text, 0) . '?=';
}
// additionally the space character should be encoded as =20 (or each
// word QP encoded separately).
// however this is needed only in mail headers, not globally in mail_quotedprintable_encode().
$text = str_replace(" ", "=20", $text);
}
} else {
$text = '';
}
// add to header comma seperated
if ($headers != '') {
$headers .= ',';
if ($header) {
$headers .= MAILHEADER_EOL . ' ';
}
// avoid overlong mail headers
}
$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;
}
开发者ID:yjliugit,项目名称:dokuwiki,代码行数:82,代码来源:mail.php
示例3: 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 <[email protected]>
* @param string $raw_id The pageid to clean
* @param boolean $ascii Force ASCII
* @return string cleaned id
*/
function cleanID($raw_id, $ascii = false)
{
global $conf;
static $sepcharpat = null;
global $cache_cleanid;
$cache =& $cache_cleanid;
if ($conf['syslog']) {
syslog(LOG_WARNING, '[pageutils.php] cleanID: raw_id: ' . $raw_id);
}
// 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);
if ($conf['mixedcase'] == 0) {
$id = utf8_strtolower($id);
}
//alternative namespace seperator
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 if specialcharacters is set to 0
if ($conf['specialcharacters'] == 0) {
$id = utf8_stripspecials($id, $sepchar, '\\*');
}
if ($ascii) {
$id = utf8_strip($id);
}
//clean up
$id = preg_replace($sepcharpat, $sepchar, $id);
$id = preg_replace('#:+#', ':', $id);
$id = trim($id, ':._-');
$id = preg_replace('#:[:\\._\\-]+#', ':', $id);
$id = preg_replace('#[:\\._\\-]+:#', ':', $id);
$cache[(string) $raw_id] = $id;
if ($conf['syslog']) {
syslog(LOG_WARNING, '[pageutils.php] cleanID: id to be returned: ' . $id);
}
return $id;
}
开发者ID:s7mx1,项目名称:dokuwiki,代码行数:64,代码来源:pageutils.php
示例4: 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 <[email protected]>
* @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;
}
开发者ID:pijoter,项目名称:dokuwiki,代码行数:54,代码来源:pageutils.php
示例5: 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']) . '?=';
}
}
}
开发者ID:boycaught,项目名称:dokuwiki,代码行数:41,代码来源:Mailer.class.php
示例6: getDynamicRedirect
/**
* Gets a dynamic redirect target based on a redirect param or the referrer.
*
* @param string|false $fallbackUrl Fallback if no redirect or referrer is available; if false, uses index
* @param boolean $useReferrer True uses the referrer if no redirect param is available
*
* @return string
*/
public function getDynamicRedirect($fallbackUrl = false, $useReferrer = true)
{
$redirect = $this->_input->filterSingle('redirect', XenForo_Input::STRING);
if (!$redirect && $useReferrer) {
$redirect = $this->_request->getServer('HTTP_X_AJAX_REFERER');
if (!$redirect) {
$redirect = $this->_request->getServer('HTTP_REFERER');
}
}
if ($redirect) {
$redirect = strval($redirect);
if (strlen($redirect) && !preg_match('/./u', $redirect)) {
$redirect = utf8_strip($redirect);
}
if (strpos($redirect, "\n") === false && strpos($redirect, "\r") === false) {
$fullRedirect = XenForo_Link::convertUriToAbsoluteUri($redirect, true);
$redirectParts = @parse_url($fullRedirect);
if ($redirectParts && !empty($redirectParts['host'])) {
$paths = XenForo_Application::get('requestPaths');
$pageParts = @parse_url($paths['fullUri']);
if ($pageParts && !empty($pageParts['host']) && $pageParts['host'] == $redirectParts['host']) {
return $fullRedirect;
}
}
}
}
if ($fallbackUrl === false) {
if ($this instanceof XenForo_ControllerAdmin_Abstract) {
$fallbackUrl = XenForo_Link::buildAdminLink('index');
} else {
$fallbackUrl = XenForo_Link::buildPublicLink('index');
}
}
return $fallbackUrl;
}
开发者ID:Sywooch,项目名称:forums,代码行数:43,代码来源:Controller.php
示例7: 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öö <[email protected]>, [email protected]","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;
}
开发者ID:JVS-IS,项目名称:ICONITO-EcoleNumerique,代码行数:69,代码来源:mail.php
示例8: utf8_rstrip
/**
* UTF-8 aware replacement for rtrim().
*
* Strip whitespace (or other characters) from the end of a string.
*
* @param string $str The UTF-8 encoded string
* @param mixed $stripchars The stripped characters
* @return string The stripped string
*/
function utf8_rstrip($str, $stripchars = null)
{
return utf8_strip($str, $stripchars, UTF8_STRIP_RIGHT);
}
开发者ID:protaskin,项目名称:utf8,代码行数:13,代码来源:special.php
示例9: testUtf8Strip
/**
* @dataProvider providerUtf8Strip
*/
public function testUtf8Strip($str, $stripchars, $rv)
{
$this->assertEquals(utf8_strip($str, $stripchars), $rv);
}
开发者ID:protaskin,项目名称:utf8,代码行数:7,代码来源:Special.php
示例10: utf8_strip
function utf8_strip($str)
{
return utf8_strip($str);
}
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:4,代码来源:utf8_integration_test.class.php
注:本文中的utf8_strip函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论