Click here to Skip to main content
15,790,884 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,
When I try to write some text into a Word file, I'm getting some strange problem as shown below.

Original text : Kšnigslutter
After writing into a file : Kšnigslutter


Path = "OutputFileName.rtf"
Dim OutputFile As FileStream
OutputFile = New FileStream(Path, FileMode.Create, FileAccess.Write)
Dim OutputStream As New StreamWriter(OutputFile, Encoding.Default)

The character š is getting replaced by š .
Please help me....

Thanks in advance.
Updated 23-Dec-09 5:08am

You say that after writing it to the file the special char gets turned into the block...but how are you checking that? What program are you using to open the .rtf? Is it possible that the program you are using doesn't know how to handle that character? Maybe I'm completely off here, but it would be something to look into.
Share this answer
Just take a look what happens when you pass
Encoding.UTF8 rather than Encoding.Default in StreamWriter object.
Share this answer
Even I tried with Encoding.UTF8, Encoding.Unicode and Encoding.ASCII. But it doesn't work.
Share this answer
It's the rtf editor (i.e. Word) rendering that's putting the box there. The character value in the file is the same, the editor just doesn't know how to interpret it. You can verify this by opening the file with a plain text editor like notepad. The "š" should be there.
Share this answer
Yep, you guys are correct.
If I open that file in Wordpad or Notepad, it's displaying properly but if I open it in MS Word 2003, it's displalying this strange ( š ) character.
Is it a problem with the MS Word 2003 or any settings/fonts of MS Word 2003.
Share this answer
How to fix this one?
Is it a problem with MS Word or any settings.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900