- Home /
WWW class doesn't read widechar url???
hi there,
i want to use WWW class to read .unity3d files from my local hard drivers,so i need to pass a string with full path like
"file://c:/myfile/../data/a.unity3d",
to WWW function (...new WWW(filepath)..).
this is ok when i pass a string in english,but,i am from asia,and my OS using widechar/unicode chars,if i pass a path string including wide char(CJK chars) ,the www class won't work!!!
like this: WWW w=new WWW("file://c:/myfile/../dat/a.unity3d");
Does WWW function only read ASCII or ANSI chars or what?? Do i need to use System.Text.encoding or something?
please help!!!
Answer by jonas-echterhoff · Apr 13, 2010 at 10:23 AM
I consider this a bug. Please file a bug report on this. But, in order for us to look into it, we need some more information, in particular, which platform are you seeing this on. The WWW class uses different implementations in the web plugin (which then depends on the browser used) and in the editor/standalone, so it is important to know which one to check.
thanks for the reply, I had tested this on windows7 and winXP,at least 4 different PCs, i am using the latest 2.6 pro version.
i had preorder the unity3,so if this is a bug, wish we can see it works in unity3 : )
standalone,also i tried other web player examples,got the same error!! i didn't in editor but i guess it will be the same!!
So, I looked into this bug, and found out it is actually a bug in libcurl, the library we use to download files - so, now we need to get them to fix it first.
Answer by Lucas Meijer 1 · May 11, 2010 at 05:29 PM
This looks like a bug indeed. You can achieve the same results by using System.IO.File.ReadAllText(".difficultfilename");
make sure that the script that contains this code itself is saved in UTF8 encoding.
thanks,do you mean, i should use the function like this? WWW w=new WWW(System.IO.File.ReadAllText("xxx.txt")); and the file name "file://c:/myfile/../dat/a.unity3d" saved in xxx.txt?
No, Lucas means you should not use WWW at all, but use System.IO.File. wether that is feasible depends on what you want to load - it won't work for AssetBundles.
Answer by ondronr · Apr 14, 2014 at 09:53 PM
Bug still present (Unity 4.3.4f1).
For further reference, if anybody wants to read local filesystem texture (from path that contains unicode chars), you can use something like:
image = new Texture2D(500, 500, textureFormat, false);
image.LoadImage(System.IO.File.ReadAllBytes(path));
Your answer
Follow this Question
Related Questions
Does Unity support UTF-8 string/text? 5 Answers
guiText.Text do not display text correctly 2 Answers
Making text appear from the bottom up 0 Answers
I want to make text appear for a few seconds and then disappear. 2 Answers
How to get offset of a ScrollRect? 0 Answers