title: Command Line arguments & "byte" arrays
body: <p>So I have a generated byte array in the form of '\xef\x00\xef\x00' blah blah blah.  The program is supposed to take this as an argument, encrypt it, and display the results.  The problem is that from command line it is '\xef\x00\xef\x00' so it doesn't work.</p>
  <p>I have tried various encodings (UTF8, Unicode, Default, etc).  I have tried different &quot;input&quot; methods, but those are not desirable due to the source of the byte array's in the first place.  The different input methods are like 0x00 format for the bytes instead.</p>
  <p>I have been googling for hours, but come up with nothing.  Most things involving a byte array is &quot;how to pass it to a method&quot; &gt;_&lt;;</p>
  <pre class="lang-cs prettyprint-override"><code>static void Main(string[] args)
  {
      //string one produces the desired results
      string one = &quot;\xfc\xe8\x82\x00\x00&quot;;
      //args[0] is the same thing as string one..just command line
      //it IS never the same as strong one once &quot;loaded&quot;
      byte[] bytes = Encoding.GetEncoding(1252).GetBytes(args[0]);
      //various messing around trying to figure it out....
      string two = Encoding.UTF8.GetString(bytes);
      byte[] oneb = StrToByteArray(one);
      byte[] twob = StrToByteArray(two);
      Console.ReadKey();
  }
  
  public static byte[] StrToByteArray(string str)
  {
      if (str != string.Empty)
      {
          byte[] sc = new byte[str.Length];
  
          for (int i = 0; i &lt; str.Length; i++)
          {
              sc[i] = Convert.ToByte(str[i]);
          }
  
          return sc;
      }
      return null;
  }
  </code></pre>
  <p>At the end...oneb and twob should be the same size, containing the same stuff.</p>