zoukankan      html  css  js  c++  java
  • 待研究

    /**
     * 计算字符串的长度(汉字按照两个字符计算)
     *
     * @param   string      $str        字符串
     *
     * @return  int
     */
    function str_len($str)
    {
        $length = strlen(preg_replace('/[\x00-\x7F]/', '', $str));

        if ($length)
        {
            return strlen($str) - $length + intval($length / 3) * 2;
        }
        else
        {
            return strlen($str);
        }
    }

    /**
     * 获得用户操作系统的换行符
     *
     * @access  public
     * @return  string
     */
    function get_crlf()
    {
    /* LF (Line Feed, 0x0A, \N) 和 CR(Carriage Return, 0x0D, \R) */
        if (stristr($_SERVER['HTTP_USER_AGENT'], 'Win'))
        {
            $the_crlf = '\r\n';
        }
        elseif (stristr($_SERVER['HTTP_USER_AGENT'], 'Mac'))
        {
            $the_crlf = '\r'; // for old MAC OS
        }
        else
        {
            $the_crlf = '\n';
        }

        return $the_crlf;
    }

  • 相关阅读:
    底图的移动(setinterval 设置移动速度)
    Arrays的一点了解
    GestureDetector
    IO问题
    IO流
    Android动画
    Android中的Manager们
    Android对话框
    Android自定义View
    Android中关于Intent
  • 原文地址:https://www.cnblogs.com/lmule/p/1852075.html
Copyright © 2011-2022 走看看