( ! ) Deprecated: Function WP_Dependencies-&gt;add_data() was called with an argument that is <strong>deprecated</strong> since version 6.9.0! IE conditional comments are ignored by all supported browsers. in /var/www/html/wp-includes/functions.php on line 6131
Call Stack
#TimeMemoryFunctionLocation
10.0000484048{main}( ).../index.php:0
20.0006484400require( '/var/www/html/wp-blog-header.php ).../index.php:17
30.24624105888require_once( '/var/www/html/wp-includes/template-loader.php ).../wp-blog-header.php:19
40.25134134880include( '/var/www/html/wp-content/themes/twentyfifteen/single.php ).../template-loader.php:125
50.25134134880get_header( $name = ???, $args = ??? ).../single.php:10
60.25134135096locate_template( $template_names = [0 => 'header.php'], $load = TRUE, $load_once = TRUE, $args = [] ).../general-template.php:48
70.25134135192load_template( $_template_file = '/var/www/html/wp-content/themes/twentyfifteen/header.php', $load_once = TRUE, $args = [] ).../template.php:749
80.25174135736require_once( '/var/www/html/wp-content/themes/twentyfifteen/header.php ).../template.php:814
90.25194143144wp_head( ).../header.php:18
100.25194143144do_action( $hook_name = 'wp_head' ).../general-template.php:3197
110.25194143360WP_Hook->do_action( $args = [0 => ''] ).../plugin.php:522
120.25194143360WP_Hook->apply_filters( $value = '', $args = [0 => ''] ).../class-wp-hook.php:365
130.25224146776wp_enqueue_scripts( '' ).../class-wp-hook.php:341
140.25224146776do_action( $hook_name = 'wp_enqueue_scripts' ).../script-loader.php:2311
150.25224146992WP_Hook->do_action( $args = [0 => ''] ).../plugin.php:522
160.25224146992WP_Hook->apply_filters( $value = '', $args = [0 => ''] ).../class-wp-hook.php:365
170.25244148880twentyfifteen_scripts( '' ).../class-wp-hook.php:341
180.25264150400wp_style_add_data( $handle = 'twentyfifteen-ie', $key = 'conditional', $value = 'lt IE 9' ).../functions.php:440
190.25264150400WP_Styles->add_data( $handle = 'twentyfifteen-ie', $key = 'conditional', $value = 'lt IE 9' ).../functions.wp-styles.php:245
200.25264150400WP_Dependencies->add_data( $handle = 'twentyfifteen-ie', $key = 'conditional', $value = 'lt IE 9' ).../class-wp-styles.php:385
210.25264150400_deprecated_argument( $function_name = 'WP_Dependencies->add_data()', $version = '6.9.0', $message = 'IE conditional comments are ignored by all supported browsers.' ).../class-wp-dependencies.php:317
220.25274156352wp_trigger_error( $function_name = '', $message = 'Function WP_Dependencies->add_data() was called with an argument that is <strong>deprecated</strong> since version 6.9.0! IE conditional comments are ignored by all supported browsers.', $error_level = 16384 ).../functions.php:5925
230.25274275888trigger_error( $message = 'Function WP_Dependencies-&gt;add_data() was called with an argument that is <strong>deprecated</strong> since version 6.9.0! IE conditional comments are ignored by all supported browsers.', $error_level = 16384 ).../functions.php:6131

( ! ) Deprecated: Function WP_Dependencies-&gt;add_data() was called with an argument that is <strong>deprecated</strong> since version 6.9.0! IE conditional comments are ignored by all supported browsers. in /var/www/html/wp-includes/functions.php on line 6131
Call Stack
#TimeMemoryFunctionLocation
10.0000484048{main}( ).../index.php:0
20.0006484400require( '/var/www/html/wp-blog-header.php ).../index.php:17
30.24624105888require_once( '/var/www/html/wp-includes/template-loader.php ).../wp-blog-header.php:19
40.25134134880include( '/var/www/html/wp-content/themes/twentyfifteen/single.php ).../template-loader.php:125
50.25134134880get_header( $name = ???, $args = ??? ).../single.php:10
60.25134135096locate_template( $template_names = [0 => 'header.php'], $load = TRUE, $load_once = TRUE, $args = [] ).../general-template.php:48
70.25134135192load_template( $_template_file = '/var/www/html/wp-content/themes/twentyfifteen/header.php', $load_once = TRUE, $args = [] ).../template.php:749
80.25174135736require_once( '/var/www/html/wp-content/themes/twentyfifteen/header.php ).../template.php:814
90.25194143144wp_head( ).../header.php:18
100.25194143144do_action( $hook_name = 'wp_head' ).../general-template.php:3197
110.25194143360WP_Hook->do_action( $args = [0 => ''] ).../plugin.php:522
120.25194143360WP_Hook->apply_filters( $value = '', $args = [0 => ''] ).../class-wp-hook.php:365
130.25224146776wp_enqueue_scripts( '' ).../class-wp-hook.php:341
140.25224146776do_action( $hook_name = 'wp_enqueue_scripts' ).../script-loader.php:2311
150.25224146992WP_Hook->do_action( $args = [0 => ''] ).../plugin.php:522
160.25224146992WP_Hook->apply_filters( $value = '', $args = [0 => ''] ).../class-wp-hook.php:365
170.25244148880twentyfifteen_scripts( '' ).../class-wp-hook.php:341
180.27954276992wp_style_add_data( $handle = 'twentyfifteen-ie7', $key = 'conditional', $value = 'lt IE 8' ).../functions.php:444
190.27954276992WP_Styles->add_data( $handle = 'twentyfifteen-ie7', $key = 'conditional', $value = 'lt IE 8' ).../functions.wp-styles.php:245
200.27954276992WP_Dependencies->add_data( $handle = 'twentyfifteen-ie7', $key = 'conditional', $value = 'lt IE 8' ).../class-wp-styles.php:385
210.27954276992_deprecated_argument( $function_name = 'WP_Dependencies->add_data()', $version = '6.9.0', $message = 'IE conditional comments are ignored by all supported browsers.' ).../class-wp-dependencies.php:317
220.27954277312wp_trigger_error( $function_name = '', $message = 'Function WP_Dependencies->add_data() was called with an argument that is <strong>deprecated</strong> since version 6.9.0! IE conditional comments are ignored by all supported browsers.', $error_level = 16384 ).../functions.php:5925
230.27964277536trigger_error( $message = 'Function WP_Dependencies-&gt;add_data() was called with an argument that is <strong>deprecated</strong> since version 6.9.0! IE conditional comments are ignored by all supported browsers.', $error_level = 16384 ).../functions.php:6131

精確的字符串截取方法 java

发开项目需要,在网上找了很久都没有打到.于是自己动手写了一下.贡献出来给有需要的人.如果有什么问题可以加我MSN:[email protected] 讨论讨论


源代码:


 /**
  * 截取字符串的前targetCount个字符
  * @param str 被处理字符串
  * @param targetCount 截取长度
  * @version 1.1
  * @author Strong Yuan
  * @return String
  */
 public static String subContentStringOrialBytes(String str,int targetCount){
  return subContentStringOrialBytes(str,targetCount,”…”);
 }
 /**
  * 获取指定长度字符串的字节长
  * @param str 被处理字符串
  * @param maxlength 截取长度
  * @author Strong Yuan
  * @version 1.1
  * @return String
  */
 private static long getStringByteLength(String str,int maxlength){
  if(str==null)
   return 0;
  int tmp_len = maxlength;
  
  if(str.length()<maxlength)
   tmp_len = str.length();
  else if(str.length()>maxlength*2)
   tmp_len = maxlength*2;
  
  char[] tempchar = str.substring(0, tmp_len).toCharArray();


  int intVariable = 0;
  String s1 = null;
  for(int i=0;i<tempchar.length && intVariable<=maxlength;i++){
   s1 = String.valueOf(tempchar[i]);
   intVariable += s1.getBytes().length;
  }
  s1= null;
  tempchar = null;
  return intVariable;
 }
 /**
  * 截取指定长度的字符串,基于bytes,即是中文的长度为2,英文为1
  * @param str 被处理字符串
  * @param targetCount 截取长度
  * @param more 后缀字符串
  * @author Strong Yuan
  * @version 1.1
  * @return
  */
 public static String subContentStringOrialBytes(String str, int targetCount,String more)
 {
  if (str == null)
   return “”;
  int initVariable = 0;
  StringBuffer restr = new StringBuffer();
  if (getStringByteLength(str,targetCount) <= targetCount)
   return str;


  String s1=null;
  byte[] b;
  char[] tempchar = str.toCharArray();
  for (int i = 0; (i < tempchar.length && targetCount > initVariable); i++) {
   s1 = String.valueOf(tempchar[i]);
   b = s1.getBytes();
   initVariable += b.length;
   restr.append(tempchar[i]);
  }


  if (targetCount == initVariable || (targetCount == initVariable – 1)) {
   restr.append(more);
  }
  return restr.toString();
 }
 /**
  * 截取指定长度的字符串,存在问题,但效率会高一点点.just a little
  * @param str 被处理字符串
  * @param targetCount 截取长度
  * @param more 后缀字符串
  * @version 1.1
  * @author Strong Yuan
  * @return String
  */
 public static String subContentStringOrial(String str,int targetCount){
  return subContentStringOrial(str,targetCount,”…”);
 } 
 /**
  * 截取指定长度的字符串,存在问题,但效率会高一点点.just a little
  * @param str 被处理字符串
  * @param targetCount 截取长度
  * @param more 后缀字符串
  * @author Strong Yuan
  * @return String
  */
 public static String subContentStringOrial(String str, int targetCount,String more)
 {
  if (str == null)
   return “”;
  int initVariable = 0;
  StringBuffer restr = new StringBuffer();
  if (str.length() <= targetCount)
   return str;


  String s1=null;
  byte[] b;
  char[] tempchar = str.toCharArray();
  for (int i = 0; (i < tempchar.length && targetCount > initVariable); i++) {
   s1 = String.valueOf(tempchar[i]);
   b = s1.getBytes();
   initVariable += b.length;
   restr.append(tempchar[i]);
  }


  if (targetCount == initVariable || (targetCount == initVariable – 1)) {
   restr.append(more);
  }
  return restr.toString();
 }


下面是性能测试:

 

public static void main(String[] args){

  int maxLength = 28;  
  String str =”当奥运圣火格式化字符串长度,超出部分显示省略号,区分汉字跟字母。汉字2个字节,字母数字一个字节格式化字符串长度,超出部分显示省略号,区分汉字跟字母。汉字2个字节,字母数字一个字节格式化字符串长度,超出部分显示省略号,区分汉字跟字母。汉字2个字节,字母数字一个字节格式化字符串长度,超出部分显示省略号,区分汉字跟字母。汉字2个字节,字母数字一个字节格式化字符串长度,超出部分显示省略号,区分汉字跟字母。汉字2个字节,字母数字一个字节格式化字符串长度,超出部分显示省略号,区分汉字跟字母。汉字2个字节,字母数字一个字节格式化字符串长度,超出部分显示省略号,区分汉字跟字母。汉字2个字节,字母数字一个字节格式化字符串长度,超出部分显示省略号,区分汉字跟字母。汉字2个字节,字母数字一个字节格式化字符串长度,超出部分显示省略号,区分汉字跟字母。汉字2个字节,字母数字一个字节格式化字符串长度,超出部分显示省略号,区分汉字跟字母。汉字2个字节,字母数字一个字节格式化字符串长度,超出部分显示省略号,区分汉字跟字母。汉字2个字节,字母数字一个字节格式化字符串长度,超出部分显示省略号,区分汉字跟字母。汉字2个字节,字母数字一个字节格式化字符串长度,超出部分显示省略号,区分汉字跟字母。汉字2个字节,字母数字一个字节格式化字符串长度,超出部分显示省略号,区分汉字跟字母。汉字2个字节,字母数字一个字节格式化字符串长度,超出部分显示省略号,区分汉字跟字母。汉字2个字节,字母数字一个字节格式化字符串长度,超出部分显示省略号,区分汉字跟字母。汉字2个字节,字母数字一个字节格式化字符串长度,超出部分显示省略号,区分汉字跟字母。汉字2个字节,字母数字一个字节格式化字符串长度,超出部分显示省略号,区分汉字跟字母。汉字2个字节,字母数字一个字节格式化字符串长度,超出部分显示省略号,区分汉字跟字母。汉字2个字节,字母数字一个字节格式化字符串长度,超出部分显示省略号,区分汉字跟字母。汉字2个字节,字母数字一个字节格式化字符串长度,超出部分显示省略号,区分汉字跟字母。汉字2个字节,字母数字一个字节格式化字符串长度,超出部分显示省略号,区分汉字跟字母。汉字2个字节,字母数字一个字节”;

  long curr = System.currentTimeMillis();
  String aa = null;
  for(int i =0;i<=100000;i++){
   aa = htmlFilter.subContentStringOrial(str, maxLength);
  }
  System.out.println(“结果: “+aa);
  System.out.println(“耗时: ” + (System.currentTimeMillis()-curr)+” ms”);
 
  curr = System.currentTimeMillis();
  for(int i =0;i<=100000;i++){
   aa = htmlFilter.subContentStringOrialBytes(str, maxLength);
  }
  System.out.println(“结果: “+aa);  
  System.out.println(“耗时: ” + (System.currentTimeMillis()-curr)+” ms”);
  

  System.out.println(htmlFilter.subContentStringOrial(“[原创]山西临汾矿难3主犯被判无期dfasdfasdfasdf万人听判”, maxLength));
  System.out.println(htmlFilter.subContentStringOrialBytes(“[原创]山西临汾矿难3主犯被判无期dfasdfasdfasdf万人听判”, maxLength,”…”));
  //存在问题,当str.length()小于maxLength时,就不进行截取
  System.out.println(htmlFilter.subContentStringOrial(“[原创]山西临汾矿难3主犯被判无期万人听判”, maxLength));
  System.out.println(htmlFilter.subContentStringOrialBytes(“[原创]山西临汾矿难3主犯被判无期万人听判”, maxLength,”…”));

}

 

最后输出结果:

 

结果: 当奥运圣火格式化字符
耗时: 1183 ms
结果: 当奥运圣火格式化字符
耗时: 1834 ms
[原创]dfasdfasdfasdf
[原创]dfasdfasdfasdf
[原创]山西临汾矿难3主
[原创]山西临汾矿难3主
[原创]山西临汾矿难3主犯被判无期万人听判判无期万人听判
[原创]山西临汾矿难3主


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.