function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dshpadshpa 

A problem with character encoding

I want to save a VF page as MS Word file. So I've added the attribute

 

contentType="application/vnd.ms-word#Test.doc"

 

to the apex:page tag. This works but some characters in the final file are replaced with another combinations. For example the hyphen is replaced with —, apostrophe - with ’ and so on. The problem is obviously related to character encoding. It can be solved with modified attribute value

 

contentType="application/vnd.ms-word; charset=Windows-1252"

 

That's fine, all text is shown normally. But I need also the default file name in this attribute like this

 

contentType="application/vnd.ms-word#Test.doc; charset=Windows-1252"

 

And this value gives the incorrect encoding again as if I remove charset value. So I can get either the right encoding or the default file name. But I need them simultaneously! I've dug up all the Internet but without any success. Also I tried to add META tag to the page and to modify HTTP headers directly but it didn't work. Can anybody help me with it?

aballardaballard

can you trty the following:

 

contentType="application/vnd.ms-word; charset=Windows-1252#Test.Doc"

themattythematty

That's exactly what fixes it, thanks a million.