1
我有一個字符串,像這樣:ASP.NET將字符串拆分成不能從objective-c工作的數組?
~SEWER/FLATWORK SUPPLY & INSTALL - 25% of CONTRACT*~SEWER/FLATWORK SUPPLY & INSTALL - 75% of CONTRACT*SUMP PUMP PIT
,這是從這個未來:
string Items = Request.QueryString["Items"];
,然後我把這個字符串並通過*
字符分割:
var ItemsArray = Items.Split('*');
但ItemsArray只返回:
~SEWER/FLATWORK SUPPLY
下面是一些有趣的事情,串項返回:〜下水道/燙平供應量也:
這裏是長什麼樣的項目,如在URL:
Items=~SEWER/FLATWORK%20SUPPLY%20&%20INSTALL%20-%2025%25%20of%20CONTRACT*~SEWER/FLATWORK%20SUPPLY%20&%20INSTALL%20-%2075%25%20of%20CONTRACT*SUMP%20PUMP%20PIT
我在objective-創建這個項目ç像這樣:
[Items appendString:[object objectForKey:@"Items"]];
[Items appendString:@"*"];
[Items deleteCharactersInRange:NSMakeRange([Items length]-1, 1)];
//This returns this: ~SEWER/FLATWORK SUPPLY & INSTALL - 25% of CONTRACT*~SEWER/FLATWORK SUPPLY & INSTALL - 75% of CONTRACT*SUMP PUMP PIT
//add Items to URL
NSString *fullURL = [NSString stringWithFormat:@"https://example.com?Items=%@, [Items stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
我期待的陣列返回,像這樣:
~SEWER/FLATWORK SUPPLY & INSTALL - 25% of CONTRACT
~SEWER/FLATWORK SUPPLY & INSTALL - 75% of CONTRACT
SUMP PUMP PIT
這裏怎麼回事?
問題是,'空間和space'是'%20%20',但應'%20%26%20'以防止解析爲查詢字符串參數 –
我將如何執行@AlexK。 – user979331
你會改變url編碼,使它在你的obj-c代碼中編碼'&',我不知道那種語言。 –