Click here to Skip to main content
15,895,142 members
Home / Discussions / C#
   

C#

 
GeneralRe: merging two word file Pin
Luc Pattyn6-Oct-10 4:50
sitebuilderLuc Pattyn6-Oct-10 4:50 
AnswerRe: merging two word file Pin
Pete O'Hanlon5-Oct-10 23:09
mvePete O'Hanlon5-Oct-10 23:09 
QuestionDatatable.BeginInit and EndInit Pin
abcurl5-Oct-10 18:17
abcurl5-Oct-10 18:17 
AnswerRe: Datatable.BeginInit and EndInit Pin
rah_sin5-Oct-10 19:40
professionalrah_sin5-Oct-10 19:40 
QuestionUnable to write Arabic text to a text file using C# [modified] Pin
Meneedhelp5-Oct-10 10:59
Meneedhelp5-Oct-10 10:59 
AnswerRe: Unable to write Arabic text to a text file using C# Pin
Luc Pattyn5-Oct-10 11:08
sitebuilderLuc Pattyn5-Oct-10 11:08 
GeneralRe: Unable to write Arabic text to a text file using C# Pin
Meneedhelp5-Oct-10 11:16
Meneedhelp5-Oct-10 11:16 
GeneralRe: Unable to write Arabic text to a text file using C# Pin
Meneedhelp5-Oct-10 11:57
Meneedhelp5-Oct-10 11:57 
I have a piece of code that reads an Arabic http link and copies the html body text to a text file. While debugging, I can see that the arabic text is being read correctly (I see arabic characters) but the output file contains weird characters. Can someone point out to me what I am doing wrong here? Here is relevant part of the code:

public string GetWebText() 
{
   byte[] data;
   mshtml.HTMLDocumentClass ms;
   string strHTML;
   mshtml.IHTMLDocument2 objMyDoc;  
   string innerText;
   TextWriter tw;
   FileInfo fi;
   int count = 0;
   Encoding curEncoding = Encoding.GetEncoding(1256);
   string htmlEncodingString = null;

   CookiedWebClient wc = new CookiedWebClient();

   fileName = path + curLangStr +".txt";
   FileStream ostrm = new FileStream(fileName, FileMode.Create, FileAccess.Write);
   tw = new StreamWriter(ostrm, curEncoding);
   int j = 0;
   try
   {
      data = wc.DownloadData("http://www.alarabonline.org");
      ms = new mshtml.HTMLDocumentClass(); 
      strHTML = curEncoding.GetString(data); 
      objMyDoc = (mshtml.IHTMLDocument2)ms;
      objMyDoc.write(strHTML);
      innerText = objMyDoc.body.innerText; 
      tw.Write(innerText); 
   }
}
catch (Exception e)
{
   Console.WriteLine("Exception message: " + e.Message +" url["+j+"] : "+urlArray[j]);
}
finally
{
   tw.Close();
   wc.Dispose();
}

return ""; 
}

GeneralRe: Unable to write Arabic text to a text file using C# Pin
Luc Pattyn5-Oct-10 13:06
sitebuilderLuc Pattyn5-Oct-10 13:06 
AnswerRe: Unable to write Arabic text to a text file using C# Pin
jschell5-Oct-10 12:21
jschell5-Oct-10 12:21 
GeneralRe: Unable to write Arabic text to a text file using C# Pin
Meneedhelp5-Oct-10 12:26
Meneedhelp5-Oct-10 12:26 
Questionc# and javascript [modified] Pin
loyal ginger5-Oct-10 8:47
loyal ginger5-Oct-10 8:47 
QuestionExcel interop Borders [Solved] - see last comment Pin
Blubbo5-Oct-10 8:03
Blubbo5-Oct-10 8:03 
AnswerRe: Excel interop Borders Pin
Abhinav S5-Oct-10 8:14
Abhinav S5-Oct-10 8:14 
GeneralRe: Excel interop Borders Pin
Blubbo5-Oct-10 8:21
Blubbo5-Oct-10 8:21 
GeneralRe: Excel interop Borders Pin
Blubbo5-Oct-10 8:37
Blubbo5-Oct-10 8:37 
GeneralRe: Excel interop Borders Pin
Abhinav S5-Oct-10 18:16
Abhinav S5-Oct-10 18:16 
Questionnavigate to the code line in a .cs file Pin
prasadbuddhika5-Oct-10 5:49
prasadbuddhika5-Oct-10 5:49 
AnswerRe: navigate to the code line in a .cs file Pin
Not Active5-Oct-10 6:52
mentorNot Active5-Oct-10 6:52 
GeneralRe: navigate to the code line in a .cs file Pin
prasadbuddhika5-Oct-10 7:02
prasadbuddhika5-Oct-10 7:02 
GeneralRe: navigate to the code line in a .cs file Pin
Not Active5-Oct-10 8:26
mentorNot Active5-Oct-10 8:26 
GeneralRe: navigate to the code line in a .cs file Pin
prasadbuddhika5-Oct-10 9:04
prasadbuddhika5-Oct-10 9:04 
AnswerRe: navigate to the code line in a .cs file [modified] Pin
Luc Pattyn5-Oct-10 6:59
sitebuilderLuc Pattyn5-Oct-10 6:59 
AnswerRe: navigate to the code line in a .cs file Pin
prasadbuddhika5-Oct-10 22:08
prasadbuddhika5-Oct-10 22:08 
GeneralRe: navigate to the code line in a .cs file Pin
Pete O'Hanlon5-Oct-10 23:00
mvePete O'Hanlon5-Oct-10 23:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.