如何编码网址?

时间:2014-05-23 09:49:20

标签: objective-c ios7 encoding

我有一个textView1,当我输入内容并按下按钮时,URL会打开。当我输入英文时,一切正常,但我也必须输入俄语并且不起作用。所以我需要编码。有人可以帮忙编码吗?

我的SozdikViewerController.h文件

import <UIKit/UIKit.h>
@interface SozdikViewController : UIViewController
@property (strong, nonatomic) IBOutlet UITextView *textView1;
@property (weak, nonatomic) IBOutlet UIButton *Button_Ask;
-(IBAction)ask;
@end

我的SozdikViewerController.m文件

#import "SozdikViewController.h"
-(IBAction)ask{


 NSString *urlString = [NSString stringWithFormat:@"http://www.audaru.kz/?product=SoylemMT&word=%@&app_request=true", [[self textView1] text]];

  NSString *newString;
newString = [urlString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:newString]];
}
@end

1 个答案:

答案 0 :(得分:0)

newString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];