当前位置: 首页>>代码示例>>PHP>>正文


PHP utf8_str_replace函数代码示例

本文整理汇总了PHP中utf8_str_replace函数的典型用法代码示例。如果您正苦于以下问题:PHP utf8_str_replace函数的具体用法?PHP utf8_str_replace怎么用?PHP utf8_str_replace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了utf8_str_replace函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: parse

 function parse()
 {
     if ($phpbb_sid = session::get('phpbb_sid')) {
         $this->xml_string = utf8_str_replace('%phpbb_sid%', $phpbb_sid, $this->xml_string);
     }
     return parent::parse();
 }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:7,代码来源:menu_parser.class.php

示例2: test_template_redirect

 function test_template_redirect()
 {
     $strategy =& new meta_redirect_strategy('/redirect_template.html');
     $path = '/to/some/place?t=1&t=2';
     $message = strings::get('redirect_message');
     $message = utf8_str_replace('%path%', $path, $message);
     $this->response->expectOnce('write', array(new WantedPatternExpectation("~<meta http-equiv=refresh content='0;" . "url=" . preg_quote($path) . "'></head>" . "<body bgcolor=white><font color=707070>~")));
     $strategy->redirect($this->response, $path);
 }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:9,代码来源:meta_redirect_strategy_test.class.php

示例3: locale_format

 function locale_format($number, $locale_string = null)
 {
     $locale = locale::instance($locale_string);
     $neg = $number < 0;
     $num = $neg ? -$number : $number;
     $num_text =& number_format($num, $locale->get_currency_fract_digits(), $locale->get_currency_decimal_symbol(), $locale->get_currency_thousand_separator());
     $text =& utf8_str_replace(array('%c', '%p', '%q'), array($locale->get_currency_symbol(), $neg ? $locale->get_currency_negative_symbol() : $locale->get_currency_positive_symbol(), $num_text), $neg ? $locale->get_currency_negative_format() : $locale->get_currency_positive_format());
     return $text;
 }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:9,代码来源:currency.class.php

示例4: nel_newline_cleanup

function nel_newline_cleanup($string)
{
    if (nel_clear_whitespace($string) !== '') {
        $string = utf8_str_replace("\r", "\n", $string);
        if (utf8_substr_count($string, "\n") < BS_MAX_COMMENT_LINES) {
            $string = utf8_str_replace("\n\n", "<br>", $string);
            $string = utf8_str_replace("\n", "<br>", $string);
        } else {
            $string = utf8_str_replace("\n", "", $string);
            // \n is erased
        }
    }
    return $string;
}
开发者ID:OtakuMegane,项目名称:Nelliel,代码行数:14,代码来源:output-filter.php

示例5: nel_render_thread_panel_thread

function nel_render_thread_panel_thread($dataforce, $render, $thread_data)
{
    $render->add_data('has_file', $thread_data['has_file']);
    $render->add_multiple_data($thread_data);
    switch (BS_DATE_FORMAT) {
        case 'ISO':
            $render->add_data('post_time', date("Y/m/d H:i:s", floor($thread_data['post_time'] / 1000)));
            break;
        case 'US':
            $render->add_data('post_time', date("m/d/Y H:i:s", floor($thread_data['post_time'] / 1000)));
            break;
        case 'COM':
            $render->add_data('post_time', date("d/m/Y H:i:s", floor($thread_data['post_time'] / 1000)));
            break;
    }
    if (utf8_strlen($thread_data['name']) > 12) {
        $render->add_data('post_name', utf8_substr($thread_data['name'], 0, 11) . "...");
    }
    if (utf8_strlen($thread_data['subject']) > 12) {
        $render->add_data('subject', utf8_substr($thread_data['subject'], 0, 11) . "...");
    }
    if ($thread_data['email']) {
        $render->add_data('post_name', '"<a href="mailto:' . $thread_data['email'] . '">' . $thread_data['name'] . '</a>');
    }
    $thread_data['comment'] = utf8_str_replace("<br>", " ", $thread_data['comment']);
    $render->add_data('comment', htmlspecialchars($thread_data['comment']));
    if (utf8_strlen($thread_data['comment']) > 20) {
        $render->add_data('comment', utf8_substr($render->retrieve_data('comment'), 0, 19) . "...");
    }
    $render->add_data('host', @inet_ntop($thread_data['host']) ? inet_ntop($thread_data['host']) : 'Unknown');
    if ($thread_data['response_to'] == '0') {
        $render->add_data('is_op', TRUE);
    } else {
        $render->add_data('is_op', FALSE);
    }
    if (!empty($thread_data['files'])) {
        $files = $thread_data['files'];
        $filecount = count($files);
        $i = 0;
        while ($i < $filecount) {
            $files[$i]['filesize'] = (int) ceil($files[$i]['filesize'] / 1024);
            ++$i;
        }
        $render->add_data('files', $files);
    }
    $render->add_data('bg_class', $dataforce['j_increment'] % 2 ? 'row1' : 'row2');
    $render->parse('thread_panel_thread.tpl', 'management');
}
开发者ID:OtakuMegane,项目名称:Nelliel,代码行数:48,代码来源:thread-panel-generation.php

示例6: nel_parse_template

function nel_parse_template($template, $subdirectory, $render, $regen)
{
    if (!empty($subdirectory)) {
        $subdirectory .= '/';
    }
    $template_short = utf8_str_replace('.tpl', '', $template);
    $info = nel_template_info($template, NULL, NULL, TRUE);
    if (is_null($info) || $info['loaded'] === FALSE || $info['loaded'] === NULL) {
        clearstatcache();
        $modify_time = filemtime(TEMPLATE_PATH . $subdirectory . $template);
        if (!isset($info['modify_time']) || $modify_time !== $info['modify_time'] || !file_exists(CACHE_PATH . $template_short . '.nelcache')) {
            $info['modify-time'] = $modify_time;
            $lol = file_get_contents(TEMPLATE_PATH . $subdirectory . $template);
            $lol = trim($lol);
            $begin = '<?php function nel_template_render_' . $template_short . '($render) { $temp = \'';
            // Start of the cached template
            $lol = preg_replace_callback('#({{.*?}})|({(.*?)})|(\')#', 'nel_escape_single_quotes', $lol);
            // Do escaping and variable parse
            $lol = preg_replace('#(})\\s*?({)#', '$1$2', $lol);
            // Clear white space between control statements
            $lol = preg_replace('#{{\\s*?(if|elseif|foreach|for|while)\\s*?(.*?)}}#', '\'; $1($2): $temp .= \'', $lol);
            // Parse opening control statements
            $lol = preg_replace('#{{\\s*?else\\s*?}}#', '\'; else: $temp .= \'', $lol);
            // Parse else statements
            $lol = preg_replace('#{{\\s*?(endif|endforeach|endfor|endwhile|endswitch)\\s*?}}#', '\'; $1; $temp .= \'', $lol);
            // Parse closing control statements
            $lol = preg_replace('#{{{\\s*?(.*?)\\s*?}}}#', '\'; $1; $temp .= \'', $lol);
            // Parse other PHP code
            $end = '\'; return $temp; } ?>';
            // End of the caches template
            $lol_out = $begin . $lol . $end;
            nel_write_file(CACHE_PATH . $template_short . '.nelcache', $lol_out, 0644);
        }
        include CACHE_PATH . $template_short . '.nelcache';
        $info['loaded'] = TRUE;
        nel_template_info($template, NULL, $info, FALSE);
    }
    if (!$regen) {
        $dat_temp = call_user_func('nel_template_render_' . $template_short, $render);
        return $dat_temp;
    }
}
开发者ID:OtakuMegane,项目名称:Nelliel,代码行数:42,代码来源:template.php

示例7: _valid_perform

 function _valid_perform(&$request, &$response)
 {
     $mail_data = $this->dataspace->export();
     if (isset($mail_data['sender_name'])) {
         $sender_name = $mail_data['sender_name'];
     } else {
         $sender_name = $mail_data['sender_firstname'] . ' ' . $mail_data['sender_lastname'];
     }
     $body = sprintf(strings::get('body_template', 'feedback'), $sender_name, $mail_data['sender_email'], $mail_data['body']);
     $body = utf8_str_replace('<br>', "\n", $body);
     $subject = $this->_get_mail_subject();
     $recipient_email = $this->_get_email();
     if (!$recipient_email || !send_plain_mail(array($recipient_email), $mail_data['sender_email'], $subject, $body)) {
         message_box::write_error(strings::get('mail_not_sent', 'feedback'));
         $request->set_status(REQUEST_STATUS_FAILUER);
         return;
     }
     message_box::write_error(strings::get('message_was_sent', 'feedback'));
     $request->set_status(REQUEST_STATUS_FORM_SUBMITTED);
     $response->redirect($_SERVER['PHP_SELF']);
 }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:21,代码来源:send_feedback_action.class.php

示例8: process

 function process($content)
 {
     $content = utf8_strtolower($content);
     $content = utf8_str_replace("\n", ' ', $content);
     $content = utf8_str_replace("\t", ' ', $content);
     $content = utf8_str_replace("\r", ' ', $content);
     $search = array("'<script[^>]*?>.*?</script>'si", "'<[\\/\\!]*?[^<>]*?>'si", "'([\r\n])[\\s]+'");
     $replace = array('', ' ', ' ');
     $content = preg_replace($search, $replace, $content);
     $content = preg_replace("#(\\.){2,}#", ' ', $content);
     $content = preg_replace("#^\\.#", ' ', $content);
     $content = preg_replace("#\\s\\.#", ' ', $content);
     $content = preg_replace("#\\.\\s#", ' ', $content);
     $content = preg_replace("#\\.\$#", ' ', $content);
     //non utf8 chars(�,�)
     $content = preg_replace("#(\\s|^)(\"|'|`|�|�)(\\w)#", '\\1\\3', $content);
     $content = preg_replace("#(\\w)(\"|'|`|�|�)(\\s|\$)#u", '\\1\\3', $content);
     $content = utf8_str_replace("&nbsp;", ' ', $content);
     $content = utf8_str_replace(":", ' ', $content);
     $content = utf8_str_replace(",", ' ', $content);
     $content = utf8_str_replace(";", ' ', $content);
     $content = utf8_str_replace("(", ' ', $content);
     $content = utf8_str_replace(")", ' ', $content);
     $content = utf8_str_replace("-", ' ', $content);
     $content = utf8_str_replace("+", ' ', $content);
     $content = utf8_str_replace("/", ' ', $content);
     $content = utf8_str_replace("!", ' ', $content);
     $content = utf8_str_replace("?", ' ', $content);
     $content = utf8_str_replace("[", ' ', $content);
     $content = utf8_str_replace("]", ' ', $content);
     $content = utf8_str_replace("\$", ' ', $content);
     $content = utf8_str_replace("\\", ' ', $content);
     $content = utf8_str_replace("<", ' ', $content);
     $content = utf8_str_replace(">", ' ', $content);
     $content = utf8_str_replace("*", ' ', $content);
     $content = utf8_trim(preg_replace("~\\s+~u", ' ', $content));
     return $content;
 }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:38,代码来源:search_text_normalizer.class.php

示例9: send_activate_password_email

 function send_activate_password_email(&$user_data, $password)
 {
     include_once LIMB_DIR . '/core/lib/mail/mail.inc.php';
     global $_SERVER;
     $http_host = $_SERVER['HTTP_HOST'];
     $filename = PROJECT_DIR . '/design/main/templates/user/generated_password_mail.html';
     if (!file_exists($filename)) {
         $filename = LIMB_DIR . '/design/default/templates/user/generated_password_mail.html';
     }
     if (!file_exists($filename)) {
         error('template file for password notification email not found!', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('file_name' => $filename));
     }
     $fd = fopen($filename, "r");
     $contents = fread($fd, filesize($filename));
     fclose($fd);
     $contents = utf8_str_replace('%website_name%', $http_host, $contents);
     $contents = utf8_str_replace('%user_name%', $user_data['name'] . ' ' . $user_data['lastname'], $contents);
     $contents = utf8_str_replace('%new_password%', $password, $contents);
     $contents = utf8_str_replace('%website_href%', $http_host, $contents);
     $contents = utf8_str_replace('%website_email%', ADMINISTRATOR_EMAIL, $contents);
     $activate_href = 'http://' . $http_host . '/root/activate_password?user=' . $user_data['email'] . '&id=' . $user_data['password'];
     $contents = utf8_str_replace('%activate_href%', $activate_href, $contents);
     if (!send_plain_mail(array($user_data['email']), ADMINISTRATOR_EMAIL, strings::get('generate_password_theme', 'user'), $contents)) {
         debug::write_error('error while sending password notification email', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__);
         return false;
     } else {
         return true;
     }
 }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:29,代码来源:user_object.class.php

示例10: nel_process_file_info

function nel_process_file_info()
{
    global $enabled_types;
    $files = array();
    $i = 0;
    $filetypes_loaded = FALSE;
    foreach ($_FILES as $file) {
        if ($file['error'] === UPLOAD_ERR_OK) {
            if (!empty($file['name'])) {
                if (!$filetypes_loaded) {
                    include INCLUDE_PATH . 'filetype.php';
                    $filetypes_loaded = TRUE;
                }
                // Grab/strip the file extension
                $files[$i]['ext'] = ltrim(strrchr($file['name'], '.'), '.');
                $files[$i]['basic_filename'] = utf8_str_replace('.' . $files[$i]['ext'], "", $file['name']);
                $max_upload = ini_get('upload_max_filesize');
                $size_unit = utf8_strtolower(utf8_substr($max_upload, -1, 1));
                $max_upload = utf8_strtolower(utf8_substr($max_upload, 0, -1));
                if ($size_unit === 'g') {
                    $max_upload = $max_upload * 1024 * 1024 * 1024;
                } else {
                    if ($size_unit === 'm') {
                        $max_upload = $max_upload * 1024 * 1024;
                    } else {
                        if ($size_unit === 'k') {
                            $max_upload = $max_upload * 1024;
                        } else {
                            // Already in bytes
                        }
                    }
                }
                if ($file['size'] > BS_MAX_FILESIZE * 1024) {
                    nel_derp(19, array('origin' => 'POST', 'bad-filename' => $files[i]['basic_filename'] . $files[i]['ext'], 'files' => array($files[$i])));
                }
                $files[$i]['dest'] = SRC_PATH . $file['name'] . '.tmp';
                move_uploaded_file($file['tmp_name'], $files[$i]['dest']);
                chmod($files[$i]['dest'], 0644);
                $files[$i]['fsize'] = filesize($files[$i]['dest']);
                $test_ext = utf8_strtolower($files[$i]['ext']);
                $file_test = file_get_contents($files[$i]['dest'], NULL, NULL, 0, 65535);
                $file_good = FALSE;
                $file_allowed = FALSE;
                // Graphics
                if (array_key_exists($test_ext, $filetypes)) {
                    if ($enabled_types['enable_' . utf8_strtolower($filetypes[$test_ext]['subtype'])] && $enabled_types['enable_' . utf8_strtolower($filetypes[$test_ext]['supertype'])]) {
                        $file_allowed = TRUE;
                        if (preg_match('#' . $filetypes[$test_ext]['id_regex'] . '#', $file_test)) {
                            $files[$i]['supertype'] = $filetypes[$test_ext]['supertype'];
                            $files[$i]['subtype'] = $filetypes[$test_ext]['subtype'];
                            $files[$i]['mime'] = $filetypes[$test_ext]['mime'];
                            $file_good = TRUE;
                        }
                    }
                }
                if (!$file_allowed) {
                    nel_derp(6, array('origin' => 'POST', 'bad-filename' => $files[i]['basic_filename'] . $files[i]['ext'], 'files' => array($files[$i])));
                }
                if (!$file_good) {
                    nel_derp(18, array('origin' => 'POST', 'bad-filename' => $files[i]['basic_filename'] . $files[i]['ext'], 'files' => array($files[$i])));
                }
                ++$i;
            }
            if ($files_count == BS_MAX_POST_FILES) {
                break;
            }
        } else {
            if ($file['error'] === UPLOAD_ERR_INI_SIZE) {
                nel_derp(19, array('origin' => 'POST', 'bad-filename' => $files[i]['basic_filename'] . $files[i]['ext'], 'files' => array($files[$i])));
            }
        }
    }
    return $files;
}
开发者ID:OtakuMegane,项目名称:Nelliel,代码行数:74,代码来源:post.php

示例11: data_handler

 function data_handler(&$parser, $data)
 {
     $data = utf8_str_replace("\t", '  ', $data);
     $this->html .= $data;
 }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:5,代码来源:template_highlight_handler.class.php

示例12: preg_replacement_quote

/**
* Adds further quotes to a regex pattern
*/
function preg_replacement_quote($replacement)
{
    $replacement = utf8_str_replace("\\", "\\\\", $replacement);
    $replacement = utf8_str_replace("\$", "\\\$", $replacement);
    return $replacement;
}
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:9,代码来源:utils.inc.php

示例13: write

 function write($string, $verbosity_level = MESSAGE_LEVEL_NOTICE, $label = '')
 {
     $this->strings[] = array('string' => utf8_str_replace("'", "\\'", $string), 'level' => $verbosity_level, 'label' => utf8_str_replace("'", "\\'", $label));
 }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:4,代码来源:message_box.class.php

示例14: nel_render_post

function nel_render_post($dataforce, $render, $response, $partial, $gen_data, $treeline, $dbh)
{
    global $link_resno;
    $render->add_data('insert_hr', $gen_data['insert_hr']);
    $post_data = $treeline[$gen_data['post_counter']];
    $render->add_multiple_data($post_data);
    if ($partial) {
        $link_resno = 0;
    } else {
        $link_resno = $dataforce['response_id'];
    }
    $render->add_data('expand_post', $gen_data['expand_post']);
    $render->add_data('first100', $gen_data['first100']);
    $render->add_data('response_id', $dataforce['response_id']);
    $render->add_data('tripcode', !is_null($post_data['tripcode']) ? BS_TRIPKEY_MARKER . $post_data['tripcode'] : '');
    $render->add_data('secure_tripcode', !is_null($post_data['secure_tripcode']) ? BS_TRIPKEY_MARKER . BS_TRIPKEY_MARKER . $post_data['secure_tripcode'] : '');
    $post_data['comment'] = nel_newline_cleanup($post_data['comment']);
    $post_data['comment'] = preg_replace('#(^|>)(&gt;[^<]*|ÅÑ[^<]*)#', '$1<span class="post-quote">$2</span>', $post_data['comment']);
    $post_data['comment'] = preg_replace_callback('#&gt;&gt;([0-9]+)#', 'nel_parse_links', $post_data['comment']);
    if (nel_clear_whitespace($post_data['comment']) === '') {
        $post_data['comment'] = nel_stext('THREAD_NOTEXT');
    }
    $render->add_sanitized_data('comment-part', utf8_str_replace('>><a href="../"', '>><a href="', $post_data['comment']));
    $render->add_sanitized_data('comment', $post_data['comment']);
    $render->add_sanitized_data('name', $post_data['name']);
    $render->add_sanitized_data('email', $post_data['email']);
    $render->add_sanitized_data('subject', $post_data['subject']);
    $render->add_data('sticky', (bool) $post_data['sticky']);
    $temp_dot = $partial ? '' : $dataforce['dotdot'];
    $post_id = $response ? $post_data['response_to'] : $post_data['post_number'];
    if (!$dataforce['omitted_done']) {
        $render->add_data('omitted_count', $gen_data['post_count'] - BS_ABBREVIATE_THREAD);
        $render->add_data('omitted_posts', TRUE);
    } else {
        $render->add_data('omitted_posts', FALSE);
    }
    if ($gen_data['has_file']) {
        $render->add_data('has_file', TRUE);
        $filecount = count($gen_data['files']);
        $render->add_data('multifile', $filecount > 1 ? TRUE : FALSE);
        $i = 0;
        $files = $gen_data['files'];
        while ($i < $filecount) {
            $files[$i]['img_dim'] = !is_null($files[$i]['image_width']) && !is_null($files[$i]['image_height']) ? TRUE : FALSE;
            $files[$i]['file_location'] = $temp_dot . SRC_DIR . $post_id . '/' . $files[$i]['filename'] . "." . $files[$i]['extension'];
            $files[$i]['filesize'] = round((int) $files[$i]['filesize'] / 1024, 2);
            if (BS1_USE_THUMB) {
                if (isset($files[$i]['preview_name'])) {
                    $files[$i]['has_preview'] = TRUE;
                    $files[$i]['preview_location'] = $temp_dot . THUMB_DIR . $post_id . '/' . $files[$i]['preview_name'];
                    if ($files[$i]['preview_width'] != 0) {
                        if ($files[$i]['preview_width'] > BS_MAX_MULTI_WIDTH || $files[$i]['preview_height'] > BS_MAX_MULTI_HEIGHT) {
                            $ratio = min(BS_MAX_MULTI_HEIGHT / $files[$i]['preview_height'], BS_MAX_MULTI_WIDTH / $files[$i]['preview_width']);
                            $files[$i]['preview_width'] = intval($ratio * $files[$i]['preview_width']);
                            $files[$i]['preview_height'] = intval($ratio * $files[$i]['preview_height']);
                        }
                    }
                } else {
                    if (BS1_USE_FILE_ICON && file_exists(BOARD_FILES . 'imagez/nelliel/filetype/' . utf8_strtolower($files[$i]['supertype']) . '/' . utf8_strtolower($files[$i]['subtype']) . '.png')) {
                        $files[$i]['has_preview'] = TRUE;
                        $files[$i]['preview_location'] = $temp_dot . BOARD_FILES . '/imagez/nelliel/filetype/' . utf8_strtolower($files[$i]['supertype']) . '/' . utf8_strtolower($files[$i]['subtype']) . '.png';
                        $files[$i]['preview_width'] = BS_MAX_WIDTH < 64 ? BS_MAX_WIDTH : '128';
                        $files[$i]['preview_height'] = BS_MAX_HEIGHT < 64 ? BS_MAX_HEIGHT : '128';
                    } else {
                        $files[$i]['has_preview'] = FALSE;
                    }
                }
            } else {
                $files[$i]['has_preview'] = FALSE;
            }
            $files[$i]['source'] = nel_cleanse_the_aids($files[$i]['source']);
            $files[$i]['license'] = nel_cleanse_the_aids($files[$i]['license']);
            $files[$i]['endline'] = ($i + 1) % BS_MAX_FILES_ROW == 0 ? TRUE : FALSE;
            ++$i;
        }
        $render->add_data('files', $files);
    } else {
        $render->add_data('multifile', FALSE);
    }
    $curr_time = floor($render->retrieve_data('post_time') / 1000);
    switch (BS_DATE_FORMAT) {
        case 'ISO':
            $render->add_data('post_time', date("Y", $curr_time) . BS_DATE_SEPARATOR . date("m", $curr_time) . BS_DATE_SEPARATOR . date("d (D) H:i:s", $curr_time));
            break;
        case 'US':
            $render->add_data('post_time', date("m", $curr_time) . BS_DATE_SEPARATOR . date("d", $curr_time) . BS_DATE_SEPARATOR . date("Y (D) H:i:s", $curr_time));
            break;
        case 'COM':
            $render->add_data('post_time', date("d", $curr_time) . BS_DATE_SEPARATOR . date("m", $curr_time) . BS_DATE_SEPARATOR . date("Y (D) H:i:s", $curr_time));
            break;
    }
    switch ($render->retrieve_data('mod_post')) {
        case '1':
            $render->add_data('staff_post', nel_stext('THREAD_JANPOST'));
            $render->add_data('secure_tripcode', '');
            break;
        case '2':
            $render->add_data('staff_post', nel_stext('THREAD_MODPOST'));
            $render->add_data('secure_tripcode', '');
            break;
//.........这里部分代码省略.........
开发者ID:OtakuMegane,项目名称:Nelliel,代码行数:101,代码来源:html-generation.php

示例15: utf8_clean

/**
 * utf8_clean( )
 * 
 * Accepts a string and removes all non-UTF-8 characters from it.
 * @since 1.0
 * 
 * @param    string $str The string to be sanitized.
 * @return   string Clean UTF-8 encoded string
 */
function utf8_clean($str, $remove_bom = false)
{
    //http://stackoverflow.com/questions/1401317/remove-non-utf8-characters-from-string
    //caused connection reset problem on larger strings
    //$regx = '/((?:[\x00-\x7F]|[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}){1,})|./';
    $regx = '/([\\x00-\\x7F]|[\\xC0-\\xDF][\\x80-\\xBF]|[\\xE0-\\xEF][\\x80-\\xBF]{2}|[\\xF0-\\xF7][\\x80-\\xBF]{3})|./s';
    $str = preg_replace($regx, '$1', $str);
    if ($remove_bom) {
        $str = utf8_str_replace(utf8_bom(), '', $str);
    }
    return $str;
}
开发者ID:henrique-lima,项目名称:rabbit-internet,代码行数:21,代码来源:Utf8Parser.php


注:本文中的utf8_str_replace函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。