如何在unitywebrequest和base64type中获取null space
how to get null space in unitywebrequest and base64type
private IEnumerator GetData()
{
WWWForm form = new WWWForm();//php에 보낼 폼을 만듦
form.AddField("data", num);
UnityWebRequest request = new UnityWebRequest();
using (request =
UnityWebRequest.Post("http://localhost/LoadData.php", form))
{
yield return request.SendWebRequest();
if (request.isNetworkError)
{
Debug.Log(request.error);
}
else
{
Debug.Log(request.downloadHandler.text.Length);
Debug.Log(request.downloadHandler.text[request.downloadHandler.text.Length - 1]);
Debug.Log(request.downloadHandler.text[request.downloadHandler.text.Length - 2]);
Debug.Log(request.downloadHandler.text[request.downloadHandler.text.Length - 3]);
string str=request.downloadHandler.text;
str = str.Substring(0, str.Length - 2);
Debug.Log(str[str.Length - 1]);
results = request.downloadHandler.data;
byte[] by = Convert.FromBase64String(request.downloadHandler.text);
Debug.Log(by.Length);
Mesh mesh = MeshSerializer.ReadMesh(by);
transform.GetComponent<MeshFilter>().mesh = mesh;
}
}
我正在发送一个字节[]作为一个统一的网络请求,但是在发送和接收时,最后添加了一个space。所以一开始我算的是这个space,但是好像每个字符长度都不一样。
base64类型好像以==结尾但是不知道这样对不对
如果你使用Unity Web Request,你能看出添加了多少个null吗?
或者有多少空值的标准?
---添加
发送到Unity Web Request后,Post->下载,字符串长度增加了2,所以一开始只删除了2。
当我一直使用这种方法时,我不知道该怎么做,因为每个对象都有不同的空长度。
只查找和比较最后一个空白列是否正确?
ZWSP:零宽度 space
https://en.wikipedia.org/wiki/Zero-width_space
如果没有以不寻常的方式收到,就会创建 ZWSP。
但不知道是data end space add ZWSP
private IEnumerator GetData()
{
WWWForm form = new WWWForm();//php에 보낼 폼을 만듦
form.AddField("data", num);
UnityWebRequest request = new UnityWebRequest();
using (request =
UnityWebRequest.Post("http://localhost/LoadData.php", form))
{
yield return request.SendWebRequest();
if (request.isNetworkError)
{
Debug.Log(request.error);
}
else
{
Debug.Log(request.downloadHandler.text.Length);
Debug.Log(request.downloadHandler.text[request.downloadHandler.text.Length - 1]);
Debug.Log(request.downloadHandler.text[request.downloadHandler.text.Length - 2]);
Debug.Log(request.downloadHandler.text[request.downloadHandler.text.Length - 3]);
string str=request.downloadHandler.text;
str = str.Substring(0, str.Length - 2);
Debug.Log(str[str.Length - 1]);
results = request.downloadHandler.data;
byte[] by = Convert.FromBase64String(request.downloadHandler.text);
Debug.Log(by.Length);
Mesh mesh = MeshSerializer.ReadMesh(by);
transform.GetComponent<MeshFilter>().mesh = mesh;
}
}
我正在发送一个字节[]作为一个统一的网络请求,但是在发送和接收时,最后添加了一个space。所以一开始我算的是这个space,但是好像每个字符长度都不一样。 base64类型好像以==结尾但是不知道这样对不对 如果你使用Unity Web Request,你能看出添加了多少个null吗? 或者有多少空值的标准?
---添加
发送到Unity Web Request后,Post->下载,字符串长度增加了2,所以一开始只删除了2。 当我一直使用这种方法时,我不知道该怎么做,因为每个对象都有不同的空长度。 只查找和比较最后一个空白列是否正确?
ZWSP:零宽度 space https://en.wikipedia.org/wiki/Zero-width_space
如果没有以不寻常的方式收到,就会创建 ZWSP。 但不知道是data end space add ZWSP