none
The generated word file is not readable (encoding problem) RRS feed

  • Question

  • Hi,

    I have developed a C++ program that uses automation to generates word files. The program writes strings into the file by use of Range.SetText(LPCTSTR ) method. Before passing my strings to this method I change the encoding of them to be 1256 ( Arabic(Windows) ). In the end, I use Document.SaveAs method to save the file with the encoding parameter set to 1256. When I run my program on my laptop which has Windows 7 on it, the text in the generated word file will be displayed correctly. But when I run it on Windows server 2003, the text in the generated word file is not correctly encoded and is not readable. The Microsoft Word installed on both computers is Word 2007.

    How can I make it work correctly on both computers?

    Thanks in advance


    Sunday, June 17, 2012 1:29 PM

All replies

  • Hi Hamidreza,

    Thank you for posting in the MSDN Forum.

    I'll involve some experts who are familiar with your issue, this may take some time.
    Much appreciate for your patient and understanding.

    Best regards,
    Quist

    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, June 19, 2012 3:12 PM
    Moderator
  • Hi,

    As I understand, you generated separate document while running the app on two different computers. One displays OK, the other doesn't. What if you run the bad document on the other computer?  This will help narrow down the issue, if it caused by system setting, or by the document generator.

    thanks,


    Forrest Guo | MSDN Community Support | Feedback to manager

    Wednesday, June 20, 2012 3:09 PM
    Moderator
  • Hi,

    I opened the bad document on the other computer, but it makes no difference. I mean the document is unreadable yet.

    I also changed my code to write UTF-8 encoded string into the file and save the file with UTF-8 encoding using SaveAs method. This changed the characters displayed when the file is open, but still the characters are unreadable ones.

    Regards,

    Hamidreza Ghader


    • Edited by Hamidreza G Wednesday, June 20, 2012 7:22 PM
    Wednesday, June 20, 2012 7:22 PM
  • OK. I try to get other people help on this query. Please wait for some time.

    thanks,


    Forrest Guo | MSDN Community Support | Feedback to manager

    Thursday, June 21, 2012 4:49 AM
    Moderator
  • Hello Harnidreza,

    The locale of the operating system could be affecting your experience. You said that the problem is on  Windows 2003 Server which  is locale dependent. Windows 7 is a universal interface where the language isn’t a factor.

    Perhaps the problem you see can be resolved by installing the appropriate language pack. Here are links to content that discuss Language Packs, Language Interface packs, and globalization of the .NET Framework 4. If you don’t have a Language Pack please consider installing one.

    Understanding Language Packs
    http://technet.microsoft.com/en-us/library/cc766472(v=WS.10).aspx

    Office Language Interface Pack (LIP) downloads - Downloads ...
    http://office.microsoft.com/en-us/downloads/office-language-interface-pack-lip-downloads-HA001113350.aspx

    NLS Knowledge Center
    http://msdn.microsoft.com/en-us/goglobal/dd565826.aspx

    .NET Framework Deployment Guide for Developers
    http://msdn.microsoft.com/en-us/library/ee942965.aspx

    .NET Framework 4: What is New in Globalization
    http://msdn.microsoft.com/en-us/netframework/dd890508.aspx


    Please remember to mark the replies as answer if they help and unmark them if they provide no help. and click "Vote as Helpful" this and other helpful posts, so other users will see your thread as useful. Best Regards, Chris Jensen

    Thursday, June 21, 2012 5:44 PM
    Moderator
  • Hello cjatms,

    Thank you for your reply. Let me ask something to help myself to understand this issue.

    I have installed right to left languages using a windows CD to my windows 2003 server. I have also set the language for programs that do not support Unicode, to be Persian, using Regional and Language setting in Control Panel. The Windows default encoding in the both operating systems is also set to be Arabic(Windows). These are not sufficient to change the locale of my Windows 2003 server and solve my problem? or Why changing the encoding of strings to UTF-8 and saving the file with UTF-8 encoding has not solved my problem?

    Regards,

    Hamidreza Ghader

    Thursday, June 21, 2012 9:43 PM
  • Hi Hamidreza,

    I’m sorry to have taken your time when covering Language Packs.  Your post says you appear to have both machines configured appropriately. Please clarify the answer you made to Forrest Gua when you said “I opened the bad document on the other computer, but it makes no difference. I mean the document is unreadable yet.” If you create another document with your program on the Windows Server 2008 system (or any Word document on that system using your program) is the resulting document unreadable?  What about a document created through the user interface of Word – not using your program?

    Do you have the same fonts on both systems?


    Please remember to mark the replies as answer if they help and unmark them if they provide no help. and click "Vote as Helpful" this and other helpful posts, so other users will see your thread as useful. Best Regards, Chris Jensen

    Friday, June 22, 2012 6:41 PM
    Moderator
  • Hi Chris,

    By that sentences I meant that I moved the document, created by my program on Windows server 2003 (bad document), to my Windows 7. But the document was still unreadable in my Windows 7.

    I have not Windows server 2008 installed anywhere on our computers, unfortunately. Thus, I m not able to test my program on Windows server 2008. Documents created through the user interface of Word has not any problem and are okay.

    I have not the same fonts on both systems. I will copy the fonts and test whether it would be helpful or not. I will provide the result here after I finish the test.

    Regards,

    Hamidreza Ghader

    Monday, June 25, 2012 9:07 AM
  • Hi Hamidreza

    It was a slip of my fat fingers, or a lapse of attention when I asked about testing the documents prepared on the Windows 7 laptop to the Windows Server "2008". I meant your Windows Server 2003.

    By your statement "Documents created through the user interface of Word has not any problem and are okay" is it correct to interpret that to mean such a document appears as intended on the Windows Server?

    That implies that the font may not be the problem. Check the default settings for styles, default fonts, and other settings of the installed Word on the Windows Server system.


    Please remember to mark the replies as answer if they help and unmark them if they provide no help. and click "Vote as Helpful" this and other helpful posts, so other users will see your thread as useful. Best Regards, Chris Jensen

    Monday, June 25, 2012 6:25 PM
    Moderator