ios瀛楃涓茬紪鐮佽浆鎹紙GBK涓嶶TF锛�8锛�

鎴戣瀹炵幇鐨勬槸灏嗘垜鐨刬os绔殑鏁版嵁閫氳繃php鍐欑殑鏈嶅姟绔啓鍏ュ埌鏁版嵁搴撲腑锛岀敱浜庤鍐欏叆涓枃淇℃伅锛屾垜php绔兘鏄敤鐨刧bk缂栫爜锛屼絾鏄祴璇曠殑鏃跺�欐暟鎹簱涓啓鍏ョ殑涓�鐩存槸涔辩爜锛屼篃鏃犳硶鍖归厤涓枃銆傛垜浠煡閬撳湪ios涓缃甦ata鐨勭紪鐮佹椂锛�NSStringEncoding榛樿鏄病鏈塯bk杩欎簺缂栫爜鐨勩��

NSString*aString =@"杩欐槸涓�涓祴璇晄tring杞珿BK鍙戦�佺殑瀛楃涓�";

NSData*aData = [aString dataUsingEncoding:NSUTF8StringEncoding];

NSString*base64String = [aData base64EncodedStringWithOptions:0];

parameters[@"printcontent"] = [NSString stringWithFormat:@"T:%@",base64String];

[self.mgrPOST:followURL parameters:parameters progress:nil success:^(NSURLSessionDataTask* _Nonnulltask ,id_Nullable responseObject) {

NSLog(@"%@",responseObject);

}failure:^(NSURLSessionDataTask* _Nullabletask ,NSError* _Nonnullerror ) {

NSLog(@"err : %@",error);

}];

鎵�浠ュ彧鑳借嚜宸卞畾涔変竴涓�NSStringEncoding瀵硅薄鏉ヨ浆鐮併��

鎸夌収涓婇潰鐨勬柟娉曞皢浠g爜淇敼濡備笅锛�

NSString*aString =@"杩欐槸涓�涓祴璇晄tring杞珿BK鍙戦�佺殑瀛楃涓�";

NSStringEncoding 聽 gbkEncoding=CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000);

NSData*aData = [aString dataUsingEncoding: gbkEncoding];

NSString*base64String = [aData base64EncodedStringWithOptions:0];

parameters[@"printcontent"] = [NSString stringWithFormat:@"T:%@",base64String];

[self.mgrPOST:followURL parameters:parameters progress:nil success:^(NSURLSessionDataTask*_Nonnulltask,id_NullableresponseObject) {

NSLog(@"%@",responseObject);

}failure:^(NSURLSessionDataTask*_Nullabletask,NSError*_Nonnullerror) {

NSLog(@"err : %@",error);

}];


杩欐牱寰�鏈嶅姟鍣ㄧ鍙戦�佺殑鏁版嵁灏辨槸gbk缂栫爜鐨勪簡锛屾暟鎹簱涓啓鍏ョ殑涔熸槸涓枃浜嗭紝涔熻兘姝g‘鍖归厤涓枃浜嗐��

你可能感兴趣的:(ios瀛楃涓茬紪鐮佽浆鎹紙GBK涓嶶TF锛�8锛�)