views:

304

answers:

1

I have a problem when loading a text file with unicode content into a UIWebview.

How can I set Encoding for the UIWebview using loadRequest like this:

[myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:tempFilePath]]];

This code seem to work but I can't use it to open MS Office file:

[myWebView loadData:[NSData dataWithContentsOfFile:tempFilePath] MIMEType:self._mimetype textEncodingName:@"UTF-8" baseURL:nil];

Thanks for helping me.

A: 

What is the value of self._mimetype?

Based on this Technote, I do not believe you will be able to open .docx (zipped-XML) files, but you should be able to open .doc files.

Also make sure that you are using the correct MIME type in the latter case (application/msword).

Alex Reynolds
Thanks for helping. I can load 2007 docs now. Need to defined correct extension for the tempFilePath. And everything will work
Tùng Đỗ