plneto / Synology.Api.Client

.NET/C# client for the Synology API
MIT License
21 stars 13 forks source link

nonascii characters in filename doesn't work in Unity #18

Open choigawoon opened 10 months ago

choigawoon commented 10 months ago

In .Net 8.0, works perfectly. but not in Unity.

here's my reproduction sample. https://github.com/choigawoon/test-unity-synology-api

open Assets/Scens/TestScene and click play after inserting infos. image


Something`s broken when doing this code.

headerValue = bytes.Aggregate("", (current, b) => current + (char) b);

In .Net 8.0

headerValue: "form-data; name=\"file\"; filename=\"ìµ\u009cê°\u0080ì\u009a´_H2_RIGHT_STAGE 2 - 2_20231220_234457_640x360.mp4\"; filename*=UTF-8''%EC%B5%9C%EA%B0%80%EC%9A%B4_H2_RIGHT_STAGE%202%20-%202_20231220_234457_640x360.mp4"

In Unity

headerValue: "form-data; name=\"file\"; filename=\"최가운_H2_RIGHT_STAGE 2 - 2_20231220_234457_640x360.mp4\"; filename*=UTF-8\'\'%EC%B5%9C%EA%B0%80%EC%9A%B4_H2_RIGHT_STAGE%202%20-%202_20231220_234457_640x360.mp4"

choigawoon commented 10 months ago

In Net8.0 (char)b convert to unicode when b is 156,

"form-data; name=\"file\"; filename=\"ìµ\u009c" (char)b = 156 '\u009c' |char|

In unity, "form-data; name=\"file\"; filename=\"최" (char)b = 'œ' |char|

i have no idea from here. how to fix it?

plneto commented 10 months ago

I'm not familiar with Unity. Is it possible to reproduce the issue using a regular .NET project?

One thing you could try is to download this project and reference it directly in your Unity project. That way it will be easier to debug the code and fix the errors. It would be great if you could try it.

choigawoon commented 10 months ago

it works in regular .NET project as i mentioned. ( .NET 8.0 ) i would have to ask to unity community about this.