Search Unity

Unable to show string that have converted from shift-jis to utf8 (Only on Device)

Discussion in 'BlackBerry' started by ARY-PRODUCTION, Aug 15, 2014.

  1. ARY-PRODUCTION

    ARY-PRODUCTION

    Joined:
    Aug 15, 2014
    Posts:
    5
    Hi there.

    I'm now testing about converting encoding.
    It means...

    1.Get shift-jis html text from web.
    2.Convert to utf8 in code.
    3.Show that on GUI.Label.

    my c# script is...
    ==========================================================
    using UnityEngine;
    using System.Collections;
    using System.IO;
    using System.Collections.Generic;
    using System.Text; //Encoding
    using System.Text.RegularExpressions;

    public class getwww : MonoBehaviour {
    public GameObject cube;
    //sjis page
    string url="http://www.metro.tokyo.jp/INET/OSHIRASE/2014/08/20o8e200.htm";
    private string str;

    void Start () {
    StartCoroutine(getURL());
    }

    IEnumerator getURL(){
    WWW www=new WWW(url);
    yield return www;
    // str=sjisToUtf(www);
    str=www.text;
    }

    // Update is called once per frame
    void Update () {
    if(Input.GetMouseButtonDown(0)){
    Instantiate(cube,transform.position,transform.rotation);
    }
    }
    void OnGUI(){
    GUI.Label(new Rect(0,0,300,500),str);
    }

    public string sjisToUtf(WWW www){
    byte[] bytesData=Encoding.Convert(Encoding.GetEncoding(932),Encoding.UTF8,www.bytes);
    string utfstr= Encoding.GetEncoding("UTF-8").GetString(bytesData);
    return utfstr;
    }
    }
    =========================================================
    Results are...

    1."sjisToUtf" unable on editor
    >> views garbled text but it's correct text.
    2."sjisToUtf" enable on editor
    >> views corrected text.
    3."sjisToUtf" unable on Debice
    >> views garbled text but it's correct text.
    and it's same with 1.
    4."sjisToUtf" enable on Device
    No views with no error.
    But application operate normally.

    I uploaded 1.~4. screenshots.
    What's wrong or any suggestions?

    editor_function_unable.png editor_function_enable.png device_function_unable.png device_function_enable.png
     
  2. AlexThibodeau

    AlexThibodeau

    Unity Technologies

    Joined:
    Jul 23, 2013
    Posts:
    309
    Looks like a bug to me. Could you submit a bug report with your project and post the case number here? I'll take a look at it.
     
  3. ARY-PRODUCTION

    ARY-PRODUCTION

    Joined:
    Aug 15, 2014
    Posts:
    5
    I reported now.
    but I could'nt know what is case number.
    You know Alex?
     
  4. ARY-PRODUCTION

    ARY-PRODUCTION

    Joined:
    Aug 15, 2014
    Posts:
    5
    Ooh,I got mail now lol
    Case number is 626398.