locked
Can't read hebrew characters from text file RRS feed

  • Question

  • Hi All,

    I create a text file that contains hebrew characters and numbers. where I read the  from the file to a String parameter I don't see the hebrew characters  , I see only the numbers.

    Hear Is The Code :

    string sLine = String.Empty;

    FileStream = new FileStream(sFileName, FileMode.Open, FileAccess.Read);

    sr = new StreamReader(fs);

    while ((sLine = sr.ReadLine()) != null)

    {

            sLine += Convert.ToChar(13); // 13 = LF

           Console.WriteLine(sLine);

    }

    Please Help

    Thanks

    Boaz Shalev.

    Thursday, September 7, 2006 12:46 PM

Answers

  • Hi All,

     

    I found  this charset appropriate to hebrew :

     

    sr = new StreamReader(fs, Encoding.GetEncoding("windows-1255"));

     

    Regards

    Boaz Shalev.

    Sunday, September 10, 2006 6:43 AM
  • Is it definately a unicode file that you are accessing? If not, you might have to specify the encoding in the StreamReader constructor:

    sr = new StreamReader(fs, System.Text.ASCIIEncoding.Default)
    or
    sr = new StreamReader(fs, System.Text.UTF8Encoding.UTF8)

    or whatever (try different encodings...)

    Thursday, September 7, 2006 1:46 PM

All replies

  • Is it definately a unicode file that you are accessing? If not, you might have to specify the encoding in the StreamReader constructor:

    sr = new StreamReader(fs, System.Text.ASCIIEncoding.Default)
    or
    sr = new StreamReader(fs, System.Text.UTF8Encoding.UTF8)

    or whatever (try different encodings...)

    Thursday, September 7, 2006 1:46 PM
  • Thanks,

    It's works.

    Boaz Shalev.

    Thursday, September 7, 2006 8:23 PM
  • Hi All,

     

    I found  this charset appropriate to hebrew :

     

    sr = new StreamReader(fs, Encoding.GetEncoding("windows-1255"));

     

    Regards

    Boaz Shalev.

    Sunday, September 10, 2006 6:43 AM