void openNewApp(const char *text)
{
NSString *url =[NSString stringWithUTF8String:text];
url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];<span style="color:#ff0000;">//假如url内包含中文</span>
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}
另一端接收解析数据
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url{
NSString* text = [NSString stringWithFormat:@"%@",url];
NSLog(@"%@",text);
UIAlertView *alertView;
NSString*text1 = [text stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
alertView = [[UIAlertView alloc] initWithTitle:@"Text---url=="
message:text1
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
[alertView release];
ClientGameUtils::sharedGameUtils()->params = const_cast<char*>([text1 cStringUsingEncoding:NSUTF8StringEncoding]) ;
enter = YES;
[self initGame];
return YES;
}
bool CGameMessageScoket::InitClientKernel(string lpszComLine, CGameHandler * pGameHander)
{
char str1[256] = {0};
// const char *str2 = "OxEx://1/tablepassword/0/1/102/418/1199/7001/二人斗牛/二人牛牛1/508df4cb2f4d8f80519256258cfb975f";
strcpy(str1 ,ClientGameUtils::sharedGameUtils()->params);
const char *token = "/";
strtok(str1, token);
char* param1 = strtok(NULL, token);
char* param2 = strtok(NULL, token);
char* param3 = strtok(NULL, token);
char* param4 = strtok(NULL, token);
char* param5 = strtok(NULL, token);
char* param6 = strtok(NULL, token);
char* param7 = strtok(NULL, token);
char* param8 = strtok(NULL, token);
char* param9 = strtok(NULL, token);
char* param10 = strtok(NULL, token);
char* param11 = strtok(NULL, token);
CCLOG("%s--%s--%s--%s--%s--%s--%s--%s--%s--%s--%s--",param1,param2,param3,param4,param5,param6,param7,param8,param9,param10,param11);
mClientUserInfo.dwUserID = atoi(param1);
mClientUserInfo.lpszTablePassword = param2;
mClientUserInfo.m_wReqChairID = atoi(param3);
mClientUserInfo.m_wReqTableID = atoi(param4);
mClientUserInfo.mKindID = atoi(param5);
mClientUserInfo.wServerID = atoi(param6);
mClientUserInfo.mServerIp = param7;
mClientUserInfo.mServerPort = atoi(param8);
ClientGameUtils::sharedGameUtils()->UTF8to16(mClientUserInfo.szKindName,param9);
ClientGameUtils::sharedGameUtils()->UTF8to16(mClientUserInfo.szServerName,param10);
ClientGameUtils::sharedGameUtils()->UTF8to16(mClientUserInfo.mLogonPassWord,param11);
g_ClientKernel->m_pGameHandler = pGameHander;
return true;
}