Answers for "WWW.text string not correct?"http://answers.unity.com/questions/844423/wwwtext-not-reading-utf-8-text.html
The latest answers for the question "WWW.text string not correct?"Answer by Andres Fernandezhttp://answers.unity.com/answers/845848/view.html
Finally the solution came from a colleague of mine, who told me that while debugging he noticed that the first three bytes of the WWW.text property were not readable characters. And yes, they were EF BB BF, i.e. the UTF-8 BOM. His workaround (that works at least on webplayer, I haven't checked other platforms) is as simple as not reading the first three bytes, since **it seems that the WWW class includes the BOM in the WWW.text string**:
WWW myWWW = new WWW(Application.dataPath + JSONurl); // UTF-8 encoded json file on the server
yield return myWWW;
string jsonData = "";
if (string.IsNullOrEmpty(myWWW.error)) {
jsonData = System.Text.Encoding.UTF8.GetString(myWWW.bytes, 3, myWWW.bytes.Length - 3); // Skip thr first 3 bytes (i.e. the UTF8 BOM)
JSONObject json = new JSONObject(jsonData); // JSONObject works now
}
Haven't checked with other parser or any other situations, but if any of you is experiencing problems with WWW.text you may want to look at the BOM inside your strings.Wed, 03 Dec 2014 08:22:43 GMTAndres FernandezAnswer by unimechanichttp://answers.unity.com/answers/845306/view.html
> I'm using JSONObject from the asset store.
> but parser doesn't like the string it receives if it comes from an UTF-8 encoded file
You might get a faster answer by getting in contact with the author. Probably they know whether this is a limitation of the plugin, or could provide a solution.Tue, 02 Dec 2014 13:42:09 GMTunimechanic