public string ConvertChinTrad(string strInput) { EncodeRobert edControl = new EncodeRobert(); string strResult = ""; if (strInput == null) { return(strResult); } if (strInput.ToString().Length >= 1) { strResult = edControl.SCTCConvert(ConvertType.Simplified, ConvertType.Traditional, strInput); } else { strResult = strInput; } return(strResult); }
protected void getText() { using (SqlConnection Sqlcon = new SqlConnection(strCon)) { using (SqlCommand cmd = new SqlCommand()) { Sqlcon.Open(); cmd.Connection = Sqlcon; cmd.CommandType = CommandType.Text; cmd.CommandText = @" SELECT * FROM third_content WHERE ID = @ID "; cmd.Parameters.Add("@ID", SqlDbType.Int); cmd.Parameters["@ID"].Value = GC_id; try { SqlAda = new SqlDataAdapter(cmd); ds = new DataSet(); SqlAda.Fill(ds); row = ds.Tables[0].Rows[0]; /// fetch content depending on the language from cookies. System.Web.HttpCookie cookie = new System.Web.HttpCookie("language"); cookie = Request.Cookies["language"]; if (cookie != null && cookie.Value != null) lang = cookie.Value; if (lang == "en") { contentPlaceholder.Text = row["content_En"].ToString(); } if (lang == "zh-HK") { if (row["content_Ch"] == null) { contentPlaceholder.Text = row["content_En"].ToString(); } else { contentPlaceholder.Text = row["content_Ch"].ToString(); } } if (lang == "zh-CN") { if (row["content_Ch"] == null) { contentPlaceholder.Text = row["content_En"].ToString(); } else { EncodeRobert edControl = new EncodeRobert();//创建一个简繁转换对象 contentPlaceholder.Text = edControl.SCTCConvert(ConvertType.Traditional, ConvertType.Simplified, row["content_Ch"].ToString());//进行简繁转换 } } } catch (Exception ex) { contentPlaceholder.Text = "Sorry we meet a problem: \n" + ex.Message; } finally { Sqlcon.Close(); } } } }
protected void getText() { using (SqlConnection Sqlcon = new SqlConnection(strCon)) { using (SqlCommand cmd = new SqlCommand()) { Sqlcon.Open(); cmd.Connection = Sqlcon; cmd.CommandType = CommandType.Text; cmd.CommandText = @" SELECT * FROM third_content WHERE ID = 20 "; try { SqlAda = new SqlDataAdapter(cmd); ds = new DataSet(); SqlAda.Fill(ds); row = ds.Tables[0].Rows[0]; /// fetch content depending on the language from cookies. System.Web.HttpCookie cookie = new System.Web.HttpCookie("language"); cookie = Request.Cookies["language"]; if (cookie != null && cookie.Value != null) lang = cookie.Value; if (lang == "en") { if (row["content_En"].ToString().Trim()!= "") { Literal1.Text = "<div><a href=''>" + row["content_En"].ToString() + "</a></div>"; } } if (lang == "zh-HK") { if (row["content_Ch"] == null) { if (row["content_En"].ToString().Trim()!= "") { Literal1.Text = "<div><a href=''>" + row["content_En"].ToString() + "</a></div>"; } } else { Literal1.Text = "<div><a href=''>" + row["content_Ch"].ToString() + "</a></div>"; } } if (lang == "zh-CN") { if (row["content_Ch"] != null) { Literal1.Text = "<div><a href=''>" + row["content_En"].ToString() + "</a></div>"; } else { EncodeRobert edControl = new EncodeRobert();//创建一个简繁转换对象 Literal1.Text = edControl.SCTCConvert(ConvertType.Traditional, ConvertType.Simplified, row["content_Ch"].ToString());//进行简繁转换 } } } catch (Exception ex) { Console.WriteLine(ex+"captured"); Literal1.Text = ""; } finally { Sqlcon.Close(); } } } }