File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -261,12 +261,14 @@ - (id)handleNetworkingResponse:(NSURLResponse *)response data:(NSData *)data
261261 // An empty body will have nil for data, in this case we need to return
262262 // an empty blob as per the XMLHttpRequest spec.
263263 data = data ?: [NSData new ];
264+ NSString *encodingName = [response textEncodingName ];
264265 return @{
265266 @" blobId" : [self store: data],
266267 @" offset" : @0 ,
267268 @" size" : @(data.length ),
268269 @" name" : RCTNullIfNil ([response suggestedFilename ]),
269270 @" type" : RCTNullIfNil ([response MIMEType ]),
271+ @" encoding" : encodingName == nil ? @" " : encodingName,
270272 };
271273}
272274
Original file line number Diff line number Diff line change @@ -34,10 +34,11 @@ @implementation RCTFileReaderModule
3434 } else {
3535 NSStringEncoding stringEncoding;
3636
37- if (encoding == nil ) {
38- stringEncoding = NSUTF8StringEncoding;
37+ NSString *encodingName = [RCTConvert NSString: blob[@" encoding" ]];
38+ if (!encodingName || [encodingName isKindOfClass: [NSNull class ]] || !encodingName.length ) {
39+ stringEncoding = NSUTF8StringEncoding;
3940 } else {
40- stringEncoding = CFStringConvertEncodingToNSStringEncoding (CFStringConvertIANACharSetNameToEncoding ((CFStringRef) encoding ));
41+ stringEncoding = CFStringConvertEncodingToNSStringEncoding (CFStringConvertIANACharSetNameToEncoding ((CFStringRef) encodingName ));
4142 }
4243
4344 NSString *text = [[NSString alloc ] initWithData: data encoding: stringEncoding];
You can’t perform that action at this time.
0 commit comments