String processing-related usage, string-related usage

Source: Internet
Author: User

String processing-related usage, string-related usage

 First, define a string:

String str = "abc ";

1. case-insensitive conversion of Characters

Uppercase: str. ToUpper ();

Lower case: str. ToLower ();

2. Conversion of characters and Ascii codes

Ascii code: byte [] B = Encoding. GetEncoding ("unicode"). GetBytes (str );
String: string s = B [0]. ToString ();

3. Conversion of Chinese character location codes

The location code of a Chinese character is a four-digit decimal number. The first two are the location code, and the last two are the location code.

Now we need a Chinese character string

String c = "I ";

Bytebyte [] B = Encoding. Default. GetBytes (str );
Short font = (short) (B [0]-'\ 0 ');

Short back = (short) (B [1]-'\ 0 ');
String s = (font-160). ToString () + (back-160). ToString ();

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.