byte[] constructor for WWW not working?

ive gotten two other WWW constructor overloads to work, but not this one:

static function WWW (url : string, postData : byte[ ]) : WWW

sorry to bug you, thanks

Can you post the code that’s not working? How are you constructing the byte array?

I do this:

byte[ ] myBytes = stringToByteArray(testPostData);
WWW httpCall = new WWW(myURL, myBytes);

private byte[ ] stringToByteArray(string s){
byte[ ] byteArray = new byte[s.ToCharArray().Length];
int i=0;
foreach( char ch in s.ToCharArray())
{
byteArray = (byte)ch;

  • i++;*
  • }*
  • return byteArray;*
  • }*
    and it just seems to fail silently
    -thanks

Because .Net uses Unicode to store text, you can no longer assume that Characters can be cast directly to bytes.

To convert a string to a byte array, you should use something like System.Text.Encoding.UTF8:

byte[] myBytes = System.Text.Encoding.UTF8.GetBytes(testPostData); 
WWW httpCall = new WWW(myURL, myBytes);

true, but the problem remains even if I create my byte[ ] any other way. have you tried it? working for you?

thanks