zoukankan      html  css  js  c++  java
  • 截取字符窜(区分中英文)

       /// <summary>
            /// 截取字符窜
            /// </summary>
            /// <param name="p_SrcString">待截取字符串</param>
            /// <param name="p_Length">截取字符串长度</param>
            /// <returns></returns>
            public static string GetSubString(string p_SrcString, int p_Length)
            {
                string myResult = p_SrcString;
                if (p_Length >= 0)
                {
                    byte[] bsSrcString = System.Text.Encoding.GetEncoding("GB2312").GetBytes(p_SrcString);
                    if (bsSrcString.Length > p_Length)
                    {
                        int nRealLength = p_Length;
                        int[] anResultFlag = new int[p_Length];
                        byte[] bsResult = null;
                        int nFlag = 0;
                        for (int i = 0; i < p_Length; i++)
                        {
                            if (bsSrcString[i] > 127)
                            {
                                nFlag++;
                                if (nFlag == 3)
                                    nFlag = 1;
                            }
                            else
                                nFlag = 0;
                            anResultFlag[i] = nFlag;
                        }
                        if ((bsSrcString[p_Length - 1] > 127) && (anResultFlag[p_Length - 1] == 1))
                            nRealLength = p_Length + 1;
                        bsResult = new byte[nRealLength];
                        Array.Copy(bsSrcString, bsResult, nRealLength);
                        myResult = Encoding.GetEncoding("GB2312").GetString(bsResult) + "...";
                    }
                }
                return myResult;
            }

  • 相关阅读:
    归一化与标准化的概念与区别
    深度学习中的优化器学习
    yolo3与yolo-tiny
    给tensorflow1.x estimator 添加timeline分析性能
    python 爬取百度图片
    TensorFlow 高性能数据输入管道设计指南
    TensorRT加速tensorflow模型(使用Tensorflow内置tensorRT,避免写自定义Plugin)
    21.Pod的limit和request和资源监控收集服务Heapster
    20.调度器,预选策略和优选策略
    8.docker的安全性
  • 原文地址:https://www.cnblogs.com/houzuofeng/p/3253294.html
Copyright © 2011-2022 走看看