字串的擷取
對路徑擷取的9種操作
nslog(@"1=%@",[index lastpathcomponent]);
nslog(@"2=%@",[index stringbydeletinglastpathcomponent]);
nslog(@"3=%@",[index pathextension]);
nslog(@"4=%@",[index stringbydeletingpathextension]);
nslog(@"5=%@",[index stringbyabbreviatingwithtildeinpath]);
nslog(@"6=%@",[index stringbyexpandingtildeinpath]);
nslog(@"7=%@",[index stringbystandardizingpath]);
nslog(@"8=%@",[index stringbyresolvingsymlinksinpath]);
nslog(@"9=%@",[[index lastpathcomponent] stringbydeletingpathextension]);
對應結果
1=2013_50.zip
3=zip
5=~/documents/download/books/2013_50.zip
9=2013_50
網路位元組順序(也就是大端模式)
htonl() //32位無符號整型的主機位元組順序到網路位元組順序的轉換(小端->>大端)
htons() //16位無符號短整型的主機位元組順序到網路位元組順序的轉換 (小端->>大端)
ntohl() //32位無符號整型的網路位元組順序到主機位元組順序的轉換 (大端->>小端)
ntohs() //16位無符號短整型的網路位元組順序到主機位元組順序的轉換 (大端->>小端)
typedef unsigned int uint_32 ;
typedef unsigned short uint_16 ;
//16位
#define bswap_16(x) \
(uint_16)((((uint_16)(x) & 0x00ff) << 8) | \
(((uint_16)(x) & 0xff00) >> 8) \
)//32位
#define bswap_32(x) \
(uint_32)((((uint_32)(x) & 0xff000000) >> 24) | \
(((uint_32)(x) & 0x00ff0000) >> 8) | \
(((uint_32)(x) & 0x0000ff00) << 8) | \
(((uint_32)(x) & 0x000000ff) << 24) \
)//無符號整型16位
uint_16 bswap_16(uint_16 x)
//無符號整型32位
uint_32 bswap_32(uint_32 x)
字串擷取
var 用 擷取 刪除左邊字元,保留右邊字元 echo 其中 var 是變數名,號是運算子,表示從左邊開始刪除第乙個 號及左邊的所有字元 結果 root localhost shell shell.sh 表示從左邊開始刪除最後 最右邊 乙個 號及左邊的所有字元 結果 將變數改為var 結果 輸出為空...
字串擷取
1.定義乙個字串a,擷取a 的某乙個專案組,複製給b,b必須是int型 nsstring a 1.2.30 int b a substringwithrange nsmakerange 4,2 intvalue nslog a n a nslog b d b output 2011 07 05 11...
字串擷取
字串擷取,支援中文和其他編碼 access public param string str 需要轉換的字串 param string start 開始位置 param string length 擷取長度 param string charset 編碼格式 param string suffix 截...