Continue nsstring Learning

Source: Internet
Author: User

I. case-insensitive Conversion
1.-(nsstring *) uppercasestring; all characters are converted to uppercase letters.
2.-(nsstring *) lowercasestring; all characters are converted to lowercase letters.
3.-(nsstring *) capitalizedstring; converts the first letter of all words into uppercase letters.

Nslog (@ "% @", [demotwo uppercasestring]);
Nslog (@ "% @", [demotwo lowercasestring]);
Nslog (@ "% @", [demotwo capitalizedstring]);


Good morning
Good morning
Good morning



5.-(nsange) linerangeforrange :( nsange) range; returns the position and length of the specified segment of the string.
Nslog (@ "% lD", [demotwo linerangeforrange: nsmakerange (7, 2)]. Length );
12


6.-(void) getparagraphstart :( nsuinteger *) startptr end :( nsuinteger *) parendptr contentsend :( nsuinteger *) contentsendptr forrange :( nsange) range; specify the Segment segment to take the string

Nsuinteger parastart, paraend, contend;
Nsstring * astring1 = @ "Apple \ u2028orange \ u2029banana \ r \ nlemon ";
[Astring1 getparagraphstart: & parastart end: & paraend contentsend: & contend forrange: nsmakerange (14, 1)];
Nslog (@ "% @", [nsstring stringwithformat: @ "paragraphstart = % d, paragraphend = % d, contentsend = % d", parastart, paraend, contend]);

8.-(nsstring *) description; returns a string.
Nslog (@ "% @", [demotwo description]);
Good morning

10. Coding
-(Nsstringencoding) fastestencoding; // The fastest encoding value of the string
-(Nsstringencoding) smallestencoding; // minimum string encoding Value
-(Nsdata *) datausingencoding :( nsstringencoding) encoding allowlossyconversion :( bool) lossy; // return the nsdata object of the specified encoding and you can select lossless conversion.
-(Nsdata *) datausingencoding :( nsstringencoding) encoding; // return the nsdata object of the specified Encoding
-(Bool) canbeconvertedtoencoding :( nsstringencoding) encoding; // you can determine whether the encoding can be lossless.

Nslog (@ "% lu", [demotwo fastestencoding]);
Nslog (@ "% lu", [demo smallestencoding]);

Nslog (@ "% @", [demotwo datausingencoding: nsshiftjisstringencoding allowlossyconversion: Yes]);
Nslog (@ "% @", [demotwo datausingencoding: nswindowscp1251stringencoding]);
Nslog (@ "% d", [demotwo canbeconvertedtoencoding: nsmacosromanstringencoding]);

30
30
<676f6f64 206d6f72 6e696e67>
<676f6f64 206d6f72 6e696e67>
1

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.