0
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;
            }
        }
        
       

I am sending a byte[] as a unity web request, but when sending and receiving, a space is added at the end. so at the beginning, I calculated this space, but it seems to be different for each character length. The base64 type seems to end with == but I don't know if this is correct If you use Unity Web Request, can you tell how many null are added? Or is there a standard for how many null are there?

---added

After sending to Unity Web Request, Post-> Download, the length of the string increased by 2, so at the beginning, only 2 deleted. As I keep using this method, I don't know what to do because each object has a different null length. Is it correct to find and compare only the last blank column?

  • Base64 pads with `=` to make the length a multiple of 3. You don't need to remove it before decoding. https://stackoverflow.com/questions/4080988/why-does-base64-encoding-require-padding-if-the-input-length-is-not-divisible-by/18518605#18518605 – Retired Ninja Sep 14 '20 at 03:08

1 Answers1

0

ZWSP: zero width space https://en.wikipedia.org/wiki/Zero-width_space

ZWSP is created if it is not received in an unusual way. but don't know that it was data end space add ZWSP