public void CreateBr(string brPath, bool useMin) { if (useMin) { RemoveChar(); } var pyShow = GetPinyins(); var dict = BuildPinyinDict(pyShow); var outPy = BuildSingleWord(pyShow, dict); Directory.CreateDirectory(brPath); File.WriteAllBytes(brPath + "/pyIndex.txt.br", CompressionUtil.BrCompress(Encoding.UTF8.GetBytes(outPy))); if (useMin == false) { var outPy2 = BuildData20000(dict); File.WriteAllBytes(brPath + "/pyIndex2.txt.br", CompressionUtil.BrCompress(Encoding.UTF8.GetBytes(outPy2))); } var words = BuildMiniWords(pyShow, dict); var ls = new List <string>(); foreach (var item in words) { var str = item; List <int> pys = dict[str]; foreach (var py in pys) { str += "," + py.ToString("X"); } ls.Add(str); } ls = ls.OrderBy(q => q).ToList(); File.WriteAllBytes(brPath + "/pyWords.txt.br", CompressionUtil.BrCompress(Encoding.UTF8.GetBytes(string.Join("\n", ls)))); }
public void WriteBr(string file) { var bytes = WritePinyinDat(); Directory.CreateDirectory(Path.GetDirectoryName(file)); File.WriteAllBytes(file, CompressionUtil.BrCompress(bytes)); }
public IActionResult VerifyCode() { #region 防止网页后退--禁止缓存 Response.Headers.Add("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1. Response.Headers.Add("Pragma", "no-cache"); // HTTP 1.0. Response.Headers.Add("Expires", "-1"); // Proxies. #endregion Random r = new Random(); string code = r.Next(10000, 100000).ToString(); SetSession(SessionSetting.AdminLoginCode, code); VerifyCode vimg = new VerifyCode(); vimg.FontSize = 30; var bytes = vimg.CreateImageBytes(code); var AcceptEncodings = Request.Headers["Accept-Encoding"].ToString().Replace(" ", "").Split(','); if (AcceptEncodings.Contains("br")) { Response.Headers["Content-Encoding"] = "br"; bytes = CompressionUtil.BrCompress(bytes, true); } else if (AcceptEncodings.Contains("gzip")) { Response.Headers["Content-Encoding"] = "gzip"; bytes = CompressionUtil.GzipCompress(bytes, true); } return(File(bytes, "image/jpg")); }
private static void Compression(string file) { var bytes = File.ReadAllBytes(file); var bs = CompressionUtil.GzipCompress(bytes); Directory.CreateDirectory("dict"); File.WriteAllBytes("dict\\" + file + ".z", bs); var bs2 = CompressionUtil.BrCompress(bytes); File.WriteAllBytes("dict\\" + file + ".br", bs2); }
private void WriteBr(string outFile, Dictionary <string, string> ts) { List <string> list = new List <string>(); foreach (var item in ts) { list.Add($"{item.Key}\t{item.Value}"); } var str = string.Join("\n", list); File.WriteAllBytes(outFile, CompressionUtil.BrCompress(Encoding.UTF8.GetBytes(str))); //File.WriteAllText(outFile, str, Encoding.UTF8); }
public void CreateBr(string pyIndex, string pyName, string outFile) { var dict = BuildPinyinDict(pyIndex, pyName); List <string> ls = new List <string>(); foreach (var item in dict) { List <string> idxs = new List <string>(); foreach (var index in item.Value) { idxs.Add(index.ToString("X")); } ls.Add($"{item.Key},{string.Join(",", idxs)}"); } Directory.CreateDirectory(Path.GetDirectoryName(outFile)); File.WriteAllBytes(outFile, CompressionUtil.BrCompress(Encoding.UTF8.GetBytes(string.Join("\n", ls)))); }