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