zoukankan      html  css  js  c++  java
  • 字符串处理的的相关用法

    首先定义一个字符串:

      string str = "abc";

    1.字符大小写转化

     大写:str.ToUpper();

     小写: str.ToLower();

    2.字符和Ascii码互相转换

    Ascii码:byte[] b = Encoding.GetEncoding("unicode").GetBytes(str);
    字符串: string s = b[0].ToString();

    3.汉字区位码转化

    汉字的区位码是一个4位的十进制数字,前两个是区位码,后两位是位码。

    现在需要一个汉字的字符串

     string c = "我";

     bytebyte[] b = Encoding.Default.GetBytes(str);
     short font = (short)(b[0] - '');

     short back = (short)(b[1] - '');
     string s = (font - 160).ToString() + (back-160).ToString();

  • 相关阅读:
    省选知识点
    寒假练习
    水题欢乐赛-套路
    2019年12月(2)
    洛谷P1347 排序
    Aizu
    2019年12月(1)
    【CSP2019】
    联系博主
    UVA1420 Priest John's Busiest Day【贪心】
  • 原文地址:https://www.cnblogs.com/Shirly-Zhang/p/5227634.html
Copyright © 2011-2022 走看看