// Start is called before the first frame update void Start() { Debug.Log("start"); txt_tra = ChineseStringUtility.ToTraditional(txt_simple); text = GetComponent <Text>(); }
// Update is called once per frame private void Update() { if (Input.GetKeyDown(KeyCode.S)) { text.text = ChineseStringUtility.ToSimplified(txt_tra); } if (Input.GetKeyDown(KeyCode.T)) { text.text = ChineseStringUtility.ToTraditional(txt_simple); } }
private void button3_Click(object sender, EventArgs e) { var inputfileName = textBox1.Text; var outputfileName = textBox2.Text; var encodingstr1 = comboBox1.Text; var encodingstr2 = comboBox2.Text; if (!File.Exists(inputfileName)) { MessageBox.Show(@"请选择需要转换的文件", @"错误!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { if (!Directory.Exists(Path.GetDirectoryName(outputfileName))) { MessageBox.Show(@"输出文件路径出错", @"错误!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } catch { MessageBox.Show(@"输出文件路径出错", @"错误!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { var origin = File.ReadAllText(inputfileName, TextEncoding.GetEncoding(encodingstr1)); string output; if (radioButton1.Checked) { output = ChineseStringUtility.ToSimplified(origin); } else if (radioButton2.Checked) { output = ChineseStringUtility.ToTraditional(origin); } else { output = origin; } File.WriteAllText(outputfileName, output, TextEncoding.GetEncoding(encodingstr2)); MessageBox.Show(@"转换成功!", @"成功!", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, @"转换出错!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// 主程序 /// </summary> public void taobao() { try { if (textBox1.Text == "") { MessageBox.Show("请打开网址"); return; } string html = GetUrlWithCookie(textBox1.Text, COOKIE, "gb2312"); Match title = Regex.Match(html, @"<title>([\s\S]*?)</title>"); //主图 MatchCollection zhupics = Regex.Matches(html, @"<a href=""#""><img([\s\S]*?)src=""([\s\S]*?)jpg"); //主图 MatchCollection prices = Regex.Matches(html, @"""price"":""([\s\S]*?)"""); //价格 // Match aURL = Regex.Match(html, @"descnew([\s\S]*?),"); //详情图来源网址 // string path = AppDomain.CurrentDomain.BaseDirectory + ChineseStringUtility.ToTraditional(title.Groups[1].Value) + "\\"; string path = textBox2.Text + "\\" + ChineseStringUtility.ToTraditional(title.Groups[1].Value) + "\\"; MessageBox.Show(path); string subPath = path + "产品介绍图\\"; //string ahtml = method.GetUrl("http://descnew"+aURL.Groups[1].Value.Replace("'","").Replace("\"",""), "gb2312"); //MatchCollection xqpics = Regex.Matches(ahtml, @"<img src=""([\s\S]*?)"""); //详情图 if (false == System.IO.Directory.Exists(path)) { //创建pic文件夹 System.IO.Directory.CreateDirectory(path); System.IO.Directory.CreateDirectory(subPath); } if (prices.Count != 0) { StringBuilder sb = new StringBuilder(); for (int a = 0; a < prices.Count; a++) { sb.Append(prices[a].Groups[1].Value + " "); } FileStream fs2 = new FileStream(path + "价格_" + prices[0].Groups[1].Value + ".txt", FileMode.Create, FileAccess.Write);//创建写入文件 StreamWriter sw2 = new StreamWriter(fs2); sw2.WriteLine(sb.ToString()); sw2.Close(); fs2.Close(); } else if (prices.Count == 0) { Match price = Regex.Match(html, @"<em class=""tb-rmb-num"">([\s\S]*?)<"); //价格 FileStream fs2 = new FileStream(path + "价格_" + price.Groups[1].Value + ".txt", FileMode.Create, FileAccess.Write); //创建写入文件 StreamWriter sw2 = new StreamWriter(fs2); sw2.WriteLine(price.Groups[1].Value); sw2.Close(); fs2.Close(); } FileStream fs1 = new FileStream(path + "网址.txt", FileMode.Create, FileAccess.Write);//创建写入文件 StreamWriter sw = new StreamWriter(fs1); sw.WriteLine(textBox1.Text); sw.Close(); fs1.Close(); for (int i = 0; i < zhupics.Count; i++) { downloadFile("http:" + zhupics[i].Groups[2].Value.Replace("https:", "") + "jpg", subPath, i + ".jpg"); textBox1.Text = "正在下载主图" + i + "\r\n"; } //for (int j = 0; j < xqpics.Count; j++) //{ // method.downloadFile(xqpics[j].Groups[1].Value , subPath, j + ".jpg"); // textBox2.Text = "正在下载详情图" + j + "\r\n"; //} MessageBox.Show("下载完成"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public void loadSDESData(int stage) { string path = stage < 10 ? "0" + stage.ToString() : stage.ToString(); string pathDir = Application.dataPath + "/Objects/DAT/Stage/Stage" + path + "/"; string pathSDES = pathDir + "SDES_" + path + ".DAT"; FileStream fs = File.OpenRead(pathSDES); byte[] bytes = new byte[fs.Length]; fs.Read(bytes, 0, (int)fs.Length); fs.Close(); data[stage].SDES.TitleT = Encoding.GetEncoding("big5").GetString(bytes, 0, 23); data[stage].SDES.WinT = Encoding.GetEncoding("big5").GetString(bytes, 0x18, 52); data[stage].SDES.LoseT = Encoding.GetEncoding("big5").GetString(bytes, 0x4C, 52); if (stage == 11) { data[stage].SDES.TitleT = "第十一幕 故人"; } data[stage].SDES.TitleS = ChineseStringUtility.ToSimplified(data[stage].SDES.TitleT); data[stage].SDES.WinS = ChineseStringUtility.ToSimplified(data[stage].SDES.WinT); data[stage].SDES.LoseS = ChineseStringUtility.ToSimplified(data[stage].SDES.LoseT); switch (stage) { case 0: data[stage].SDES.ProficiencyS = "获得燧石"; break; case 1: data[stage].SDES.ProficiencyS = "获得全部宝物"; break; case 2: data[stage].SDES.ProficiencyS = "获得全部宝物"; break; case 3: data[stage].SDES.ProficiencyS = "获得全部宝物"; break; case 4: data[stage].SDES.ProficiencyS = "敌全灭+1"; break; case 5: data[stage].SDES.ProficiencyS = "获得全部宝物"; break; case 6: data[stage].SDES.ProficiencyS = "获得全部宝物"; break; case 7: data[stage].SDES.ProficiencyS = "获得全部宝物"; break; case 8: data[stage].SDES.ProficiencyS = "不让不净散人攻击朱慎"; break; case 9: data[stage].SDES.ProficiencyS = "获得全部宝物"; break; case 10: data[stage].SDES.ProficiencyS = "击败夏候仪"; break; case 11: data[stage].SDES.ProficiencyS = "不让天玄门弟子阵亡"; break; case 12: data[stage].SDES.ProficiencyS = "获得全部宝物"; break; case 13: data[stage].SDES.ProficiencyS = "同时击败高世津和灵山老人"; break; case 14: data[stage].SDES.ProficiencyS = "获得全部宝物"; break; case 15: data[stage].SDES.ProficiencyS = "二十回合内击倒夏侯仪并四回合内击倒鬼魄尸王"; break; case 16: data[stage].SDES.ProficiencyS = "救下至少九名禁军士兵"; break; case 17: data[stage].SDES.ProficiencyS = "三十五回合内敌全灭"; break; case 18: data[stage].SDES.ProficiencyS = "无"; break; case 19: data[stage].SDES.ProficiencyS = "击杀敌人数小于8"; break; case 20: data[stage].SDES.ProficiencyS = "除韩无砂外的敌全灭"; break; case 21: data[stage].SDES.ProficiencyS = "二十回合内结束本关"; break; case 22: data[stage].SDES.ProficiencyS = "不让封寒月攻击韩无砂+1"; break; case 23: data[stage].SDES.ProficiencyS = "获得全部宝物+1"; break; case 24: data[stage].SDES.ProficiencyS = "获得全部宝物+1"; break; case 25: data[stage].SDES.ProficiencyS = "获得全部宝物+1"; break; case 26: data[stage].SDES.ProficiencyS = "十五回合以上结束本关+1"; break; case 27: data[stage].SDES.ProficiencyS = "获得全部宝物+1"; break; case 28: data[stage].SDES.ProficiencyS = "获得全部宝物+1"; break; case 29: data[stage].SDES.ProficiencyS = "获得全部宝物+1"; break; case 30: data[stage].SDES.ProficiencyS = "获得全部宝物+1"; break; case 31: data[stage].SDES.ProficiencyS = "无"; break; case 32: data[stage].SDES.ProficiencyS = "获得全部宝物+1"; break; case 33: data[stage].SDES.ProficiencyS = "获得全部宝物+1"; break; case 34: data[stage].SDES.ProficiencyS = "无"; break; case 35: data[stage].SDES.ProficiencyS = "无"; break; } data[stage].SDES.ProficiencyT = ChineseStringUtility.ToTraditional(data[stage].SDES.ProficiencyS); }
public void init(string str) { stringS = str; stringT = ChineseStringUtility.ToTraditional(str); }