( ! ) 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.0000484208{main}( ).../index.php:0
20.0006484560require( '/var/www/html/wp-blog-header.php ).../index.php:17
30.31454109584require_once( '/var/www/html/wp-includes/template-loader.php ).../wp-blog-header.php:19
40.32004138688include( '/var/www/html/wp-content/themes/twentyfifteen/archive.php ).../template-loader.php:125
50.32004138688get_header( $name = ???, $args = ??? ).../archive.php:19
60.32004138904locate_template( $template_names = [0 => 'header.php'], $load = TRUE, $load_once = TRUE, $args = [] ).../general-template.php:48
70.32004139000load_template( $_template_file = '/var/www/html/wp-content/themes/twentyfifteen/header.php', $load_once = TRUE, $args = [] ).../template.php:749
80.32034139544require_once( '/var/www/html/wp-content/themes/twentyfifteen/header.php ).../template.php:814
90.32054146952wp_head( ).../header.php:18
100.32054146952do_action( $hook_name = 'wp_head' ).../general-template.php:3197
110.32054147168WP_Hook->do_action( $args = [0 => ''] ).../plugin.php:522
120.32054147168WP_Hook->apply_filters( $value = '', $args = [0 => ''] ).../class-wp-hook.php:365
130.32074150584wp_enqueue_scripts( '' ).../class-wp-hook.php:341
140.32074150584do_action( $hook_name = 'wp_enqueue_scripts' ).../script-loader.php:2311
150.32074150800WP_Hook->do_action( $args = [0 => ''] ).../plugin.php:522
160.32074150800WP_Hook->apply_filters( $value = '', $args = [0 => ''] ).../class-wp-hook.php:365
170.32084277104twentyfifteen_scripts( '' ).../class-wp-hook.php:341
180.32104278624wp_style_add_data( $handle = 'twentyfifteen-ie', $key = 'conditional', $value = 'lt IE 9' ).../functions.php:440
190.32104278624WP_Styles->add_data( $handle = 'twentyfifteen-ie', $key = 'conditional', $value = 'lt IE 9' ).../functions.wp-styles.php:245
200.32104278624WP_Dependencies->add_data( $handle = 'twentyfifteen-ie', $key = 'conditional', $value = 'lt IE 9' ).../class-wp-styles.php:385
210.32104278624_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.32104278944wp_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.32104279696trigger_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.0000484208{main}( ).../index.php:0
20.0006484560require( '/var/www/html/wp-blog-header.php ).../index.php:17
30.31454109584require_once( '/var/www/html/wp-includes/template-loader.php ).../wp-blog-header.php:19
40.32004138688include( '/var/www/html/wp-content/themes/twentyfifteen/archive.php ).../template-loader.php:125
50.32004138688get_header( $name = ???, $args = ??? ).../archive.php:19
60.32004138904locate_template( $template_names = [0 => 'header.php'], $load = TRUE, $load_once = TRUE, $args = [] ).../general-template.php:48
70.32004139000load_template( $_template_file = '/var/www/html/wp-content/themes/twentyfifteen/header.php', $load_once = TRUE, $args = [] ).../template.php:749
80.32034139544require_once( '/var/www/html/wp-content/themes/twentyfifteen/header.php ).../template.php:814
90.32054146952wp_head( ).../header.php:18
100.32054146952do_action( $hook_name = 'wp_head' ).../general-template.php:3197
110.32054147168WP_Hook->do_action( $args = [0 => ''] ).../plugin.php:522
120.32054147168WP_Hook->apply_filters( $value = '', $args = [0 => ''] ).../class-wp-hook.php:365
130.32074150584wp_enqueue_scripts( '' ).../class-wp-hook.php:341
140.32074150584do_action( $hook_name = 'wp_enqueue_scripts' ).../script-loader.php:2311
150.32074150800WP_Hook->do_action( $args = [0 => ''] ).../plugin.php:522
160.32074150800WP_Hook->apply_filters( $value = '', $args = [0 => ''] ).../class-wp-hook.php:365
170.32084277104twentyfifteen_scripts( '' ).../class-wp-hook.php:341
180.34914280800wp_style_add_data( $handle = 'twentyfifteen-ie7', $key = 'conditional', $value = 'lt IE 8' ).../functions.php:444
190.34914280800WP_Styles->add_data( $handle = 'twentyfifteen-ie7', $key = 'conditional', $value = 'lt IE 8' ).../functions.wp-styles.php:245
200.34914280800WP_Dependencies->add_data( $handle = 'twentyfifteen-ie7', $key = 'conditional', $value = 'lt IE 8' ).../class-wp-styles.php:385
210.34914280800_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.34914281120wp_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.34924281344trigger_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主