开发者

C# WindowsApp TextBox with Special Characters

开发者 https://www.devze.com 2022-12-22 09:53 出处:网络
I would like to include a textbox / richtextbox in which I would like to include text such as \"jogħġbok żomm din il-bieb magħluq\".

I would like to include a textbox / richtextbox in which I would like to include text such as

"jogħġbok żomm din il-bieb magħluq". 

When I putting this text in the textbox/rightext box I am getting the following:

jogħġbok żomm din il-bieb magħluq

Can you please help?

I am getting the string from google transla开发者_JS百科te:

        string url = String.Format("http://www.google.com/translate_t?hl=en&ie=UTF8&text={0}&langpair={1}", 
            input, languagePair);
        WebClient webClient = new WebClient();
        webClient.Encoding = System.Text.Encoding.UTF8;
        string result = webClient.DownloadString(url);
        result = result.Substring(result.IndexOf("<span title=\"") + "<span title=\"".Length);
        result = result.Substring(result.IndexOf(">") + 1);
        result = result.Substring(0, result.IndexOf("</span>"));
        return result.Trim();

Edit:

I would like to convert:

"jog&#295;&#289;bok &#380;omm din il-bieb mag&#295;luq"

to

"jogħġbok żomm din il-bieb magħluq"


you can convert the html text with System.Web.HttpUtility.HtmlDecode:

        string str = "jog&#295;&#289;bok &#380;omm din il-bieb mag&#295;luq";
        str = System.Web.HttpUtility.HtmlDecode(str); 
        textBox1.Text = str;
        richTextBox1.Text = str;
0

精彩评论

暂无评论...
验证码 换一张
取 消