I'm building a level into a C# string using each char to hold two different elements. I'm using all 16 bits in each char. I'm able to save the level off in a text file and read it back in with no issues. It's ugly to look at because a number of chars match something that equals null. When I tried sending it to PHP (code below) I immediately echoed back the string I received. Upon first glance the data was wrong. Upon checking the bits in each string I could see that there was no real relation between the two strings that were supposed to be the same.
public static void UploadLevel(int userID, string levelData)
{
Debug.Log("LEVEL OUT:");
Scene_Editor.LevelToBinary(levelData);
using (var client = new WebClient())
{
var values = new NameValueCollection();
values["uid"] = userID.ToString();
values["leveldata"] = levelData;
var response = client.UploadValues("http://example.com/uploadlevel.php", values);
var responseString = System.Text.Encoding.UTF32.GetString(response);
Debug.Log("levelData BACK");
Scene_Editor.LevelToBinary(responseString);
}
}
And here is uploadlevel.php
<?php
echo $_POST['leveldata'];
?>
Here is a very short example of a level converted to a string (3 chars is the smallest, and can go up to 99 chars).
Level Out: ㄐ
Broken down into binary:
0) 0010001011111111 (no char seems to be associated with this value)
1) 0011000100010000 (ㄐ)
2) 0010000001100000 (no char seems to be associated with this value)
Level Back: 询還
Broken down into binary:
0) 1000101111100010 (询)
1) 1001000010000100 (還)
Now, I don't even necessarily need this to be a string as long as I can store it in a database and get it back and convert the bits back into a level. Any ideas? Also, I'm using .net 4.0.