File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed
Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ typedef enum {
2626 NSString *password;
2727 int timeout;
2828 NSMutableDictionary *requestHeaders;
29+ NSStringEncoding defaultEncoding;
2930
3031 EJHttpRequestState state;
3132 NSURLConnection *connection;
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ @implementation EJBindingHttpRequest
77- (id )initWithContext : (JSContextRef)ctxp argc : (size_t )argc argv : (const JSValueRef [])argv {
88 if ( self = [super initWithContext: ctxp argc: argc argv: argv] ) {
99 requestHeaders = [[NSMutableDictionary alloc ] init ];
10+ defaultEncoding = NSASCIIStringEncoding;
1011 }
1112 return self;
1213}
@@ -53,7 +54,7 @@ - (NSInteger)getStatusCode {
5354- (NSString *)getResponseText {
5455 if ( !response || !responseBody ) { return NULL ; }
5556
56- NSStringEncoding encoding = NSASCIIStringEncoding ;
57+ NSStringEncoding encoding = defaultEncoding ;
5758 if ( response.textEncodingName ) {
5859 CFStringEncoding cfEncoding = CFStringConvertIANACharSetNameToEncoding ((CFStringRef) response.textEncodingName );
5960 if ( cfEncoding != kCFStringEncodingInvalidId ) {
@@ -220,8 +221,9 @@ - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
220221
221222 NSURL *requestUrl = [NSURL URLWithString: url];
222223 if ( !requestUrl.host ) {
223- // No host? Assume we have a local file
224+ // No host? Assume it's a local file in utf8 encoding
224225 requestUrl = [NSURL fileURLWithPath: [scriptView pathForResource: requestUrl.path]];
226+ defaultEncoding = NSUTF8StringEncoding;
225227 }
226228 NSMutableURLRequest *request = [[NSMutableURLRequest alloc ] initWithURL: requestUrl];
227229 [request setHTTPMethod: method];
You can’t perform that action at this time.
0 commit comments