title: How to convert hebrew (unicode) to Ascii in c#?
body: <p>I have to create some sort of text file in which there are numbers and Hebrew letters decoded to ASCII.</p>
  
  <p>This is file creation method which triggers on ButtonClick</p>
  
  <pre><code>protected void ToFile(object sender, EventArgs e)
  {
      filename = Transactions.generateDateYMDHMS();
      string path = string.Format("{0}{1}.001", Server.MapPath("~/transactions/"), filename);
      StreamWriter sw = new StreamWriter(path, false, Encoding.ASCII);
      sw.WriteLine("hello");
      sw.WriteLine(Transactions.convertUTF8ASCII("שלום"));
      sw.WriteLine("bye");
      sw.Close();
  }
  </code></pre>
  
  <p>as you can see, i use Transactions.convertUTF8ASCII() static method to convert from probably Unicode string from .NET to ASCII representation of it. I use it on term Hebrew 'shalom' and get back '????' instead of result i need.</p>
  
  <p>Here is the method.</p>
  
  <pre><code>public static string convertUTF8ASCII(string initialString)
  {
      byte[] unicodeBytes = Encoding.Unicode.GetBytes(initialString);
      byte[] asciiBytes = Encoding.Convert(Encoding.Unicode, Encoding.ASCII, unicodeBytes);
      return Encoding.ASCII.GetString(asciiBytes);
  }
  </code></pre>
  
  <p>Instead of having initial word decoded to ASCII i get '????' in the file i create even if i run debbuger i get same result.</p>
  
  <p>What i'm doing wrong ?</p>