人人做人人澡人人爽欧美,国产主播一区二区,久久久精品五月天,羞羞视频在线观看免费

當前位置:蘿卜系統下載站 > 技術開發教程 > 詳細頁面

字符串處理:中英文混排固定長度截取問題

字符串處理:中英文混排固定長度截取問題

更新時間:2022-09-04 文章作者:未知 信息來源:網絡 閱讀次數:

/// <summary>
  /// 從包含中英文的字符串中截取固定長度的一段,strInput為傳入字符串,intLen為截取長度(一個漢字占兩個位)。
  /// </summary>
  public string cutString(string strInput,int intLen)
  {
   strInput=strInput.Trim();
   byte[] myByte = System.Text.Encoding.Default.GetBytes(strInput);   
   if(myByte.Length>intLen)
   {
    //截取操作
    string resultStr="";
    for(int i=0;i<strInput.Length;i++){
     byte[] tempByte=System.Text.Encoding.Default.GetBytes(resultStr);
     if(tempByte.Length<intLen-4)
     {
      resultStr+=strInput.Substring(i,1);
     }
     else{
      break;
     }     
    }
    return resultStr+" ...";
   }
   else{
    return strInput;
   }
  }


溫馨提示:喜歡本站的話,請收藏一下本站!

本類教程下載

系統下載排行

網站地圖xml | 網站地圖html
主站蜘蛛池模板: 永寿县| 卢湾区| 大庆市| 泰安市| 宾川县| 卓尼县| 容城县| 盐山县| 西畴县| 康定县| 茶陵县| 建阳市| 黑龙江省| 太白县| 水城县| 铜鼓县| 怀来县| 道孚县| 萍乡市| 琼结县| 孝义市| 新昌县| 灵台县| 平遥县| 邮箱| 大田县| 宁津县| 双峰县| 浦北县| 子洲县| 香港 | 黑河市| 营口市| 吉安市| 衡阳县| 公主岭市| 白银市| 班玛县| 恩施市| 象山县| 鄂尔多斯市|