protected override void Walk <TContext>(WalkOptions options, TContext context, Func <TContext, ISqlExpression, ISqlExpression> func) { base.Walk(options, context, func); Expr2 = Expr2.Walk(options, context, func) !; Escape = Escape?.Walk(options, context, func); }
public static string domainRun(string url, string sendData) { Stream requestStream; byte[] bytes = Encoding.GetEncoding("UTF-8").GetBytes(Escape.escape(sendData)); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.PreAuthenticate = (true); request.Method = ("POST"); request.SendChunked = (false); request.ContentType = ("text/xml"); request.ContentLength = ((long)bytes.Length); try { requestStream = request.GetRequestStream(); } catch (Exception exception) { return(url + " : " + exception.Message); } requestStream.Write(bytes, 0, bytes.Length); requestStream.Close(); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("UTF-8")); string str = reader.ReadToEnd(); reader.Close(); response.Close(); return(str); }
public override void ConvertToCp932(byte[] dataIn, int offsetIn, int lengthIn, byte[] dataOut, int offsetOut, int lengthOut, bool flush, Escape escape, out int usedIn, out int usedOut, out bool complete) { usedIn = 0; usedOut = 0; complete = false; var index1 = offsetIn; var index2 = offsetOut; var num1 = 0; var count = 0; var limit = this.CalculateLoopCountLimit(lengthIn); if (escape.IsValidEscapeSequence) { if (!this.IsEscapeSequenceHandled(escape)) throw new System.InvalidOperationException(string.Format("unhandled escape sequence: {0}", escape.Sequence)); index1 += escape.BytesInCurrentBuffer; isKana = escape.Sequence == EscapeSequence.JisX0201K_1976 || escape.Sequence == EscapeSequence.ShiftOut; isEscapeKana = escape.Sequence == EscapeSequence.JisX0201K_1976; } for (; index1 < offsetIn + lengthIn; ++index1) { this.CheckLoopCount(ref count, limit); var num2 = dataIn[index1]; switch (num2) { case 27: case 0: goto label_16; case 14: isKana = true; break; case 15: isKana = isEscapeKana; break; default: if (num2 < 128) { dataOut[index2] = !isKana || (int) num2 < 33 || (int) num2 > 95 ? num2 : (byte) (num2 + 128U); ++index2; ++num1; break; } if (num2 >= 161 && num2 <= 223) { dataOut[index2] = num2; ++index2; ++num1; break; } if (num2 == 160) { dataOut[index2] = 32; ++index2; ++num1; break; } dataOut[index2] = 63; ++index2; ++num1; break; } } label_16: complete = index1 == offsetIn + lengthIn; usedIn = index1 - offsetIn; usedOut = num1; }
protected override void Walk(WalkOptions options, Func <ISqlExpression, ISqlExpression> func) { base.Walk(options, func); Expr2 = Expr2.Walk(options, func) !; Escape = Escape?.Walk(options, func); }
public void TestJSStringEscaper_String() { // Assume the string is within an HTML <script> tag, like so: // <script> var = 'TAINTED_DATA_HERE'; </script> string beforeEscape = "close context'\" continue context \\ break context " + "\u2029 \u2028 escape HTML context & </script>" + " control chars: \b \t \n \u000b \f %22"; string afterEscape = Escape.JsString(beforeEscape); string[] badSequences = { "'", "\"", " \\ ", "\u2028", "\u2029", "&", "\b","\t", "\n", "\u000b", "\f", "%", "</script>", }; foreach (var badSequence in badSequences) { Assert.IsFalse(afterEscape.Contains(badSequence)); } }
protected override void Execute(CodeActivityContext context) { var sb = new StringBuilder(); var hd = new List <String>(); foreach (DataColumn c in Source.Get(context).Columns) { hd.Add(c.ColumnName); } sb.AppendLine(CreateLine(hd.ToArray(), Escape.Get(context))); foreach (DataRow row in Source.Get(context).Rows) { var body = new List <String>(); for (int i = 0; i < Source.Get(context).Columns.Count; i++) { if (Source.Get(context).Columns[i].DataType == typeof(DateTime) || row[i].GetType() == typeof(DateTime)) { body.Add(row[i] != null ? ((DateTime)row[i]).ToString(DateTimeFormat.Get(context)) : null); } else { body.Add(row[i].ToString()); } } sb.AppendLine(CreateLine(body.ToArray(), Escape.Get(context))); } System.Windows.Clipboard.SetText(sb.ToString()); }
public void TestHTMLEscaper_Transtions() { foreach (var sensitiveCharacter in HTML_SENSITIVE_CHARS) { Assert.IsFalse(Escape.Html(sensitiveCharacter).Contains(sensitiveCharacter)); } }
// Start is called before the first frame update void Start() { defaultSpeed = moveSpeed; controller = this.GetComponent <CharacterController>(); anim = this.GetComponent <Animator>(); health = 3; oxygen = 60; invulnerable = false; holding = false; gm = FindObjectOfType <GameManager>(); nm = FindObjectOfType <NetworkManager>(); walkingSFX = this.GetComponent <AudioSource>(); InvokeRepeating("PlayWalkingNoise", 0, 0.4f); healthBar = GameObject.Find("HealthBar").GetComponent <Slider>(); oxygenBar = GameObject.Find("OxygenBar").GetComponent <Slider>(); oxygen_color = GameObject.Find("OxygenColor").GetComponent <Text>(); oxygen2_color = GameObject.Find("Oxygen2Color").GetComponent <Text>(); oxygenCue = GameObject.Find("Oxygen Cue").GetComponent <Animator>(); damageCue = GameObject.Find("Damage Cue").GetComponent <Animator>(); escapeObj = GameObject.Find("Escape2"); canTeleport = escapeObj.GetComponent <Escape>(); }
private void method_1() { ShortMap inputMap = this.cellExt1_0.getCell(0, 0).InputMap; if (inputMap != null) { object obj2 = inputMap[601]; if (obj2 is string) { string src = (string)obj2; if ((src != null) && (src.Length != 0)) { src = Escape.unescape(src); XmlDocument document = new XmlDocument(); document.LoadXml(src); for (int i = 0; i < document.DocumentElement.ChildNodes.Count; i++) { Class7 class2 = new Class7 { id = document.DocumentElement.ChildNodes[i].ChildNodes[0].InnerText, cols = Convert.ToInt32(document.DocumentElement.ChildNodes[i].ChildNodes[1].InnerText) }; class2.keyCol = document.DocumentElement.ChildNodes[i].ChildNodes[2].InnerText.Trim().Split(new char[] { ',' }); class2.keyNums = class2.keyCol.Length; this.arrayList_0.Add(class2); } } } } }
void pickEscapePoint(Escape prevPoint) { if (_escapePoints.Count <= 0) { Debug.LogError("Escape Manager: There were no escape points assigned!"); return; } // Player has a previous escape point. if (prevPoint) { List <Escape> temp = new List <Escape>(_escapePoints); temp.Remove(prevPoint); int randomIndex = Random.Range(0, temp.Count); _currEscapeIndex = randomIndex; _currEscapePoint = temp[randomIndex]; } // Player does not have a previous escape point. else { int randomIndex = Random.Range(0, _escapePoints.Count); _currEscapeIndex = randomIndex; _currEscapePoint = _escapePoints[randomIndex]; } }
private void prepareEnv(string args, Env env, ReportDefine rd) { var collection = new Hashtable(); if (!string.IsNullOrEmpty(args)) { string[] arrayItem = args.Split(new[] { '&' }); for (int i = 0, length = arrayItem.Length; i < length; i++) { string item = arrayItem[i]; if ((item != null) && (item.Trim().Length > 0)) { string[] arrayVar = arrayItem[i].Split(new[] { '=' }); if (arrayVar.Length == 2) { string key = arrayVar[0]; string src = arrayVar[1]; if ((src != null) && (src.Trim().Length != 0)) { SupportClass.PutElement(collection, key, Escape.unescape(src)); } } } } } preapareArgs(rd, collection, env); prepareDataSource(rd.DataSetConfigs.getDataSourceNames(), env); }
void updateDiamondGrabbed(bool diamondGrabbed, int escapeIndex) { _diamondGrabbed = diamondGrabbed; if (!_diamondGrabbed) { _vignette.intensity.value = 0.0f; } // Escape point stuff if (escapeIndex <= 0) { _currEscapePoint = null; } else { _currEscapePoint = _escapePoints[escapeIndex]; } if (diamondGrabbed && _currEscapePoint) { _currEscapePoint.turnOn(); } else if (_currEscapePoint) { _currEscapePoint.turnOff(); } }
/// <summary> /// Escapes and optionally quotes a command line argument. /// </summary> /// <param name="value">The command line argument.</param> /// <returns>The escaped and optionally quoted command line argument.</returns> public static string EscapeArgument(string value) { if (value == null) { return(null); } int length = value.Length; if (length == 0) { return(string.Empty); } var sb = new StringBuilder(); Escape.AppendQuotedText(sb, value); if (sb.Length == length) { return(value); } return(sb.ToString()); }
public void ParseSingleZIS() { var result = @"MSH|^~\&|DIP|Blood Lab|LIS|XYZ Laboratory|20160818131019376||MFR^M01|VMSG14|P|2.4| MSA|AA|12345678|22237649|INFORM HPV HR Tissue| ZIS|1234^PR^PI|20160817082024472|Hemo|"; var parser = new PipeParser(); var escapedResult = Escape.unescape(result, new EncodingCharacters('|', '^', '~', '\\', '&')); var resultMessage = parser.Parse(escapedResult); var r = resultMessage as MFR_M01; if (r == null) { throw new InvalidOperationException( $"Result was expected to be {typeof(MFR_M01)}, but was {resultMessage.GetType()}"); } var zis = r.ZIS_GROUPS.First() .ZIS; Assert.AreEqual(zis.Identifier.Identifier.Value, "1234"); Assert.AreEqual(zis.Identifier.Text.Value, "PR"); Assert.AreEqual(zis.Identifier.NameOfCodingSystem.Value, "PI"); Assert.AreEqual(zis.DateTimeOfCreation.TimeOfAnEvent.Value, "20160817082024472"); Assert.AreEqual(zis.Procedure.Value, "Hemo"); }
public void TraverseVariable(int depth, Variable var) { if (var == null) { return; } else if (var is SimpleVariable) { Escape escape = EscapeEnv[(var as SimpleVariable).Name] as Escape; if (escape == null) { ; } if (escape.Depth < depth) { escape.SetEscape(); } } else if (var is FieldVariable) { TraverseVariable(depth, (var as FieldVariable).Var); } else if (var is SubscriptVariable) { TraverseVariable(depth, (var as SubscriptVariable).Var); TraverseExpression(depth, (var as SubscriptVariable).Index); } }
public override void ConvertToCp932(byte[] dataIn, int offsetIn, int lengthIn, byte[] dataOut, int offsetOut, int lengthOut, bool flush, Escape escape, out int usedIn, out int usedOut, out bool complete) { usedIn = 0; usedOut = 0; var index = offsetIn; var num = offsetOut; var count = 0; var limit = this.CalculateLoopCountLimit(lengthIn); if (escape.IsValidEscapeSequence) { if (!this.IsEscapeSequenceHandled(escape)) throw new System.InvalidOperationException(string.Format("unhandled escape sequence: {0}", escape.Sequence)); index += escape.BytesInCurrentBuffer; } for (; index < offsetIn + lengthIn; dataOut[num++] = dataIn[index++]) { this.CheckLoopCount(ref count, limit); switch (dataIn[index]) { case 27: case 15: case 14: case 0: goto label_9; default: if (num + 1 > offsetOut + lengthOut) throw new System.InvalidOperationException(string.Format("DecodeUsAsciiToCp932.ConvertToCp932: output buffer overrun, offset {0}, length {1}", offsetOut, lengthOut)); continue; } } label_9: complete = index == offsetIn + lengthIn; usedIn = index - offsetIn; usedOut = num - offsetOut; }
private void setSeriesStr(Chart Chart1, ChartParam servletrequest, string SeriesName, string SeriesNo, string pName) { string src = servletrequest.getParameter(SeriesNo + pName); if ((src != null) && (src.Length > 0)) { switch (pName) { case "name": Chart1.Series[SeriesName].Name = src; break; case "Href": Chart1.Series[SeriesName].Href = Escape.unescape(src); break; case "LegendHref": Chart1.Series[SeriesName].LegendHref = Escape.unescape(src); break; case "MapAreaAttributes": Chart1.Series[SeriesName].MapAreaAttributes = Escape.unescape(src); break; case "LegendMapAreaAttributes": Chart1.Series[SeriesName].LegendMapAreaAttributes = Escape.unescape(src); break; case "CustomAttributes": Chart1.Series[SeriesName].CustomAttributes = Escape.unescape(src); break; } } }
public void CreateMFR_M01withZIS() { var mfr_m01 = new MFR_M01(); PopulateMessageHeaders(mfr_m01.MSH, nameof(MFR_M01)); var zisGroup = mfr_m01.AddZIS(); var zis = zisGroup.ZIS; zis.Identifier.Identifier.Value = "1234"; zis.Identifier.Text.Value = "PIR"; zis.Identifier.NameOfCodingSystem.Value = "Hemo"; zis.DateTimeOfCreation.TimeOfAnEvent.SetLongDateWithSecond(_fixedDate); zisGroup.ZIS.Procedure.Value = "TOT"; var parser = new PipeParser(); var encodedString = parser.Encode(mfr_m01); var escapedString = Escape.unescape(encodedString, new EncodingCharacters('|', '^', '~', '\\', '&')); Assert.AreEqual(escapedString, "MSH|^~\\&|TEST|Test Facility|VIP||20160701124512||MFR_M01|636139528780284680|P|2.4\rZIS|1234^PIR^Hemo|20160701124512|TOT\r"); }
public void TestJSStringEscaper_Transtions() { foreach (var sensitiveCharacter in JS_STRING_SENSITIVE_CHARS) { Assert.IsFalse(Escape.JsString(sensitiveCharacter).Contains(sensitiveCharacter)); } }
private void Update() { if (Input.GetMouseButtonDown(0)) { MainAction?.Invoke(); } if (Input.GetKeyDown(KeyCode.Escape)) { Escape?.Invoke(); } if (Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.KeypadEnter)) { InteractAction?.Invoke(); } if (Input.GetKeyDown(KeyCode.Alpha1)) { SetActiveSlot?.Invoke(1); } if (Input.GetKeyDown(KeyCode.Alpha2)) { SetActiveSlot?.Invoke(2); } if (Input.GetKeyDown(KeyCode.BackQuote)) { ToggleAnimVisibility?.Invoke(); } }
public object calculate(CellExt1 cs, DataSet ds, Env env, string param) { UnitSet set; this.cs = cs; this.ds = ds; this.env = env; string str = (string)ConvertTool.getValue(new ExpParse(cs, ds, env, param).calculate()); if ((str != null) && (str.Trim().Length > 0)) { set = new UnitSet(Escape.removeEscAndQuote(str), true, '&'); } else { set = new UnitSet("", true, '&'); } string expStr = Escape.unescape(set["dataXml"]); object obj2 = ConvertTool.getValue(new ExpParse(cs, ds, env, expStr).calculate()); this.pDataXml = (string)obj2; CellExt current = cs.Current; StringBuilder sb = new StringBuilder(); object obj3 = null; try { obj3 = this.cal(set, sb); } catch (Exception exception) { throw new ReportError("统计图计算异常:" + exception.Message.ToString().ToString(), exception); } return(obj3); }
private static string GetString(Random random, int minLength, int maxLength, Escape escape) { int length = random.Next(minLength, maxLength); var array = new char[length]; if (escape != Escape.AllEscaped) { for (int i = 0; i < length; i++) { array[i] = (char)random.Next(97, 123); } if (escape == Escape.OneEscaped) { if (random.NextDouble() > 0.5) { array[random.Next(0, length)] = '"'; } } } else { array.AsSpan().Fill('"'); } return(new string(array)); }
public void TestNestedURLInCSSInHTMLEscaper_String() { // Assume the string is within an HTML style attribute, like so: // <span style="background-image:url('TAINTED_DATA_HERE')">... string beforeEscape = "javascript:alert(1) break child context % close parent context ') escape" + " parent context \" escape parent context </span>"; string afterEscape = Escape.Html(Escape.CssString(Escape.Uri(beforeEscape))); string[] badSequences = { "javascript:", "javascriptA;", // shouldn't occur, in case it did would still fire javascript: uri " % ", "  ", "')", "\n", "\"", "</span>" }; foreach (var badSequence in badSequences) { Assert.IsFalse(afterEscape.Contains(badSequence)); } }
public void OnLoad() { Variables.Hero = ObjectManager.LocalHero; this.pause = Variables.Hero.ClassID != ClassID.CDOTA_Unit_Hero_Meepo; if (this.pause) { return; } Variables.MenuManager = new MenuManager(Me.Name); Variables.MenuManager.Menu.AddToMainMenu(); Variables.EnemyTeam = Me.GetEnemyTeam(); this.meepoControls = new MeepoControls(); this.jungleFarm = new JungleFarm(); this.stack = new Stack(); this.escape = new Escape(); this.laning = new Laning(); this.combo = new Combo(); this.poofAllToCloestToMouse = new PoofAllToClosestToMouse(); foreach (var camp in JungleCamps.GetCamps) { camp.canBeHere = true; } Game.PrintMessage( "MeepoSharpPlus" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version + " loaded", MessageType.LogMessage); }
public void TestHtmlEscaper_Whitespace() { foreach (var sensitiveCharacter in WEB_WHITESPACES) { Assert.IsFalse(Escape.Html(sensitiveCharacter).Contains(sensitiveCharacter)); } }
private void InitModes() { ScoreDisplay = new ScoreDisplay(this, 1); ScoreDisplay.layer.enabled = false; BaseMode = new BaseMode(this, 2); AttractMode = new Attract(this, 20); SkillshotMode = new Skillshot(this, 3); PagesMode = new PageMode(this, 5); CellarRampMode = new CellarRamp(this, 6); TargetsMode = new Targets(this, 25); WorkshedMode = new WorkShed(this, 30); ShedMultiball = new ShedMball(this, 35); BumpersMode = new Bumpers(this, 40); DeadByDawnMode = new DeadByDawn(this, 50); SelectMode = new ModeSelect(this, 40); Lindamode = new Linda(this, 40); CherylMode = new Cheryl(this, 40); BadHandMode = new BadHand(this, 40); EscapeMode = new Escape(this, 40); ShellyMode = new Shelly(this, 40); Modes.Add(ScoreDisplay); Modes.Add(BaseMode); Modes.Add(AttractMode); Modes.Add(TargetsMode); Modes.Add(WorkshedMode); }
public virtual string this[string key] { get { return(Escape.removeEscAndQuote(this.ss[key])); } }
public string uploadFile() { string str = ""; string str2 = Escape.unescape(this.httpRequest_0.Params["setpath"]); string str3 = PathTool.getRealPath(this.httpRequest_0, basePath + str2); str = "<script> var arr = new Array();"; str = str + "arr[0]=parent.pubFileName;" + "arr[1]=parent.pubBz;"; Stream stream = this.httpRequest_0.Files[("pic")].InputStream; int num = (int)stream.Length; byte[] buffer = new byte[num]; stream.Read(buffer, 0, num); string str4 = this.httpRequest_0.Files[("pic")].FileName; string str5 = ""; int num2 = str4.LastIndexOf("."); str5 = str4.Substring(num2, str4.Length - num2); Guid guid = Guid.NewGuid(); FileStream stream2 = new FileStream(str3 + guid.ToString() + str5, (FileMode)2); if (stream2.CanWrite) { stream2.Write(buffer, 0, num); } stream2.Close(); string str6 = str; return((str6 + "arr[2]='" + str2 + guid.ToString() + str5 + "';") + "parent.returnValue=arr;parent.opener=null;parent.close();</script>"); }
public Escape(Escape from) { Sequence = from.Sequence; this.State = from.State; this.BytesInCurrentBuffer = from.BytesInCurrentBuffer; this.TotalBytes = from.TotalBytes; this.ErrorMessage = from.ErrorMessage; }
//<tr bgcolor="#B7CFEB" align="center" style="background-color: rgb(143, 186, 236);"> // <td align="left"><a href="mission.do?act=look&mission_id=3976" target="_black"><font class="zi14" color="black">高原白花的地图</font></a> <img alt="南十字星第四章" src="http://dols.enorth.com.cn/jpg\edition\CDS4.gif"></td> // <td>0</td> // <td align="left"> // <img alt="生态调查" src="http://dols.enorth.com.cn/jpg\skill\stdc.gif"><img alt="" src="http://dols.enorth.com.cn/jpg/num/5.gif"><img alt="生物学" src="http://dols.enorth.com.cn/jpg\skill\swx.gif"><img alt="" src="http://dols.enorth.com.cn/jpg/num/5.gif"> // </td> // <td>0/0<br></td> // <td align="left">热那亚门外 白花附近</td> // <td align="left"> // <img alt="植物" src="http://dols.enorth.com.cn/jpg\distype\zw.jpg" width="20" height="20"> //<font color="red">1★</font> //<a href="discover.do?act=look&discover_id=3642" target="_black"><font color="red">火绒草</font></a> // <br> // <font color="#804000"> </font> // <br> // <a href="mission.do?act=list&link=pl8_mt0lt0pl0" target="_black">那不勒斯</a> // </td> // </tr> public static Dol.Base.Quest GetQuest(HtmlNode node) { //first td,first a var quest = new Dol.Base.Quest(); var href = node.SelectSingleNode("td[1]").SelectSingleNode("a[1]").Attributes["href"].Value; quest.ID = Int32.Parse(missionRegex.Match(href).Groups["id"].Value); quest.Name = node.SelectSingleNode("td[1]").SelectSingleNode("a[1]").InnerText; quest.Name = quest.Name.Replace("“", ""); quest.Name = Consistency.Parse(quest.Name); quest.Star = Int32.Parse(node.SelectSingleNode("td[2]").InnerText); quest.Skill = SkillHandler.ParseSkill(node.SelectSingleNode("td[3]")); var award = node.SelectSingleNode("td[4]").InnerText.Split('/'); quest.Exp = Int32.Parse(award[0]); var fameStr=numRegex.Replace(award[1], ""); quest.Fame = Int32.Parse(fameStr); var escape = new Escape(); var raw=node.SelectSingleNode("td[5]").InnerHtml; raw=Consistency.Parse(raw); quest.Content = raw; var remark=RemarkHandler.ParseRemark(node.SelectSingleNode("td[6]")); quest.FromCityList = remark.FromCityList; quest.AwardItem = remark.AwardItem; quest.Discovery = remark.Discovery; quest.DiscoveryID = remark.DiscoveryID; quest.DiscoveryLevel = remark.DiscoveryLevel; quest.DiscoveryType = remark.DiscoveryType; quest.FollowQuestID = remark.FollowQuestID; quest.PreFoundName = remark.PreFoundName; quest.PreQuestID = remark.PreQuestID; //Content解析 POIs.Land.Concat(POIs.Citys).All(name => { var index = raw.IndexOf(name); while (index != -1) { //POIs.Count[name] = POIs.Count[name] + 1; if (!quest.RoutesDic.Keys.Contains(index)) { quest.RoutesDic.Add(index, name); } index = raw.IndexOf(name, index + name.Length); } return true; }); var keys=quest.RoutesDic.Keys.ToArray(); var lastRoute=String.Empty; foreach (var key in keys) { var route = quest.RoutesDic[key]; if (lastRoute == route) { quest.RoutesDic.Remove(key); } lastRoute = route; } return quest; }
public void UnescapeText_InputIsUnescapable_ReturnsUnescapedValue(string input, string expected) { // Arrange // Act var actual = Escape.UnescapeText(input, encodingCharacters); // Assert Assert.AreEqual(expected, actual); }
public void TestAllStringEscaper_Transtions() { foreach (var sensitiveCharacter in WEB_NEW_LINES) { Assert.IsFalse(Escape.Html(sensitiveCharacter).Contains(sensitiveCharacter)); Assert.IsFalse(Escape.CssString(sensitiveCharacter).Contains(sensitiveCharacter)); Assert.IsFalse(Escape.JsString(sensitiveCharacter).Contains(sensitiveCharacter)); } }
public void WhenStringIsEscaped_AndThenUnescaped_InputIsIdenticalToOutput() { var expected = "\\.br\\ Lipid - Target Levels for Treatment \\.br\\\\.br\\ ****************************************************************\\.br\\ \\F\\ Risk \\F\\ \\F\\ \\F\\\\.br\\ \\F\\ Level \\F\\ 10-year CAD risk \\F\\ Recommendations \\F\\\\.br\\ \\F\\---------\\F\\------------------\\F\\---------------------------------\\F\\\\.br\\ \\F\\ \\F\\ \\F\\Treatment targets: \\F\\\\.br\\ \\F\\High* \\F\\ >=20% \\F\\ Primary: LDL-C <2.0 mmol/L \\F\\\\.br\\ \\F\\ \\F\\ \\F\\ Secondary: TC/HDL-C <4.0 \\F\\\\.br\\ \\F\\---------\\F\\------------------\\F\\---------------------------------\\F\\\\.br\\ \\F\\ \\F\\ \\F\\Treat when: \\F\\\\.br\\ \\F\\Moderate \\F\\ 10 - 19 % \\F\\ LDL-C >=3.5 mmol/L\\F\\\\.br\\ \\F\\ \\F\\ \\F\\ or TC/HDL-C >=5.0 \\F\\\\.br\\ \\F\\---------\\F\\------------------\\F\\---------------------------------\\F\\\\.br\\ \\F\\ \\F\\ \\F\\Treat when: \\F\\\\.br\\ \\F\\Low \\F\\ <10% \\F\\ LDL-C >=5.0 mmol/L\\F\\\\.br\\ \\F\\ \\F\\ \\F\\ or TC/HDL-C >=6.0 \\F\\\\.br\\****************************************************************\\.br\\ Notes:\\.br\\ * 10-year coronary artery disease (CAD) risk is accessed by\\.br\\ Framingham risk estimate tables.\\.br\\ * *High risk includes CAD, peripheral artery disease, cerebro-\\.br\\ vascular disease (CVD) and most patients with chronic kidney\\.br\\ disease or established diabetes mellitus.\\.br\\ * The patient must have been fasting for at least 12 hours prior\\.br\\ to taking ablood sample.\\.br\\ * Calculation: LDL-C (mmol/L) = Chol - (HDL-C + 0.46 x TG).\\.br\\ Calculation is invalid if TG exceed 4.5 mmol/L.\\.br\\ Ref: McPherson R et al. Can J Cardiol. 2006 Sep;22(11):913-27\r"; var escaped = Escape.EscapeText(expected, encodingCharacters); var actual = Escape.UnescapeText(escaped, encodingCharacters); Assert.AreEqual(expected, actual); }
public void ShouldEncodeVariableValue() { var evaluator = MockRepository.GenerateMock <IEvaluator>(); evaluator.Stub(x => x.Encode("unencoded")).Return("encoded"); var result = new Escape().Evaluate("unencoded", evaluator); Assert.AreEqual("encoded", result); }
public override ValidationResult GetRunLength(byte[] dataIn, int offsetIn, int lengthIn, Escape escape, out int usedIn, out int usedOut) { usedIn = 0; usedOut = 0; var index = offsetIn; var num1 = 0; var count = 0; var limit = this.CalculateLoopCountLimit(lengthIn); if (escape.IsValidEscapeSequence) { if (!this.IsEscapeSequenceHandled(escape)) throw new System.InvalidOperationException(string.Format("unhandled escape sequence: {0}", escape.Sequence)); index += escape.BytesInCurrentBuffer; } else if (escape.Sequence == EscapeSequence.NotRecognized) { index += escape.BytesInCurrentBuffer; num1 += escape.BytesInCurrentBuffer; } while (index < offsetIn + lengthIn) { this.CheckLoopCount(ref count, limit); var num2 = dataIn[index]; if (num2 != 27 && num2 != 15 && (num2 != 14 && num2 != 0)) { if (num2 == 160) { ++index; ++num1; } else { if (num2 >= 129 && num2 <= 159 || num2 >= 224 && num2 <= 252) { ++index; ++num1; if (index >= offsetIn + lengthIn || dataIn[index] == 0) break; } ++index; ++num1; } } else break; } usedIn = index - offsetIn; usedOut = num1; return ValidationResult.Valid; }
public override ValidationResult GetRunLength(byte[] dataIn, int offsetIn, int lengthIn, Escape escape, out int usedIn, out int usedOut) { usedIn = 0; usedOut = 0; var index = offsetIn; var num1 = 0; var flag = false; var validEscapeSequence = escape.IsValidEscapeSequence; var count = 0; var limit = this.CalculateLoopCountLimit(lengthIn); if (validEscapeSequence) { if (!this.IsEscapeSequenceHandled(escape)) throw new System.InvalidOperationException(string.Format("unhandled escape sequence: {0}", escape.Sequence)); index += escape.BytesInCurrentBuffer; } while (index < offsetIn + lengthIn) { this.CheckLoopCount(ref count, limit); var num2 = dataIn[index]; switch (num2) { case 27: case 15: case 14: goto label_10; default: if ((num2 <= sbyte.MaxValue || validEscapeSequence) && num2 != 0) { if ((num2 < 32 || num2 > sbyte.MaxValue) && (num2 != 9 && num2 != 10) && (num2 != 11 && num2 != 12 && num2 != 13)) flag = true; ++index; ++num1; continue; } goto label_10; } } label_10: usedIn = index - offsetIn; usedOut = num1; return !flag || validEscapeSequence ? ValidationResult.Valid : ValidationResult.Invalid; }
public override bool IsEscapeSequenceHandled(Escape escape) { if (escape.Sequence != EscapeSequence.JisX0208_1978 && escape.Sequence != EscapeSequence.JisX0208_1983) return escape.Sequence == EscapeSequence.JisX0208_1990; return true; }
public override bool IsEscapeSequenceHandled(Escape escape) { return escape.Sequence == EscapeSequence.Iso646Irv; }
public override bool IsEscapeSequenceHandled(Escape escape) { return true; }
public override void ConvertToCp932(byte[] dataIn, int offsetIn, int lengthIn, byte[] dataOut, int offsetOut, int lengthOut, bool flush, Escape escape, out int usedIn, out int usedOut, out bool complete) { usedIn = 0; usedOut = 0; complete = false; var index1 = offsetIn; var num1 = offsetOut; var num2 = 0; var count = 0; var limit = this.CalculateLoopCountLimit(lengthIn); if (escape.IsValidEscapeSequence) { if (!this.IsEscapeSequenceHandled(escape)) throw new System.InvalidOperationException(string.Format("unhandled escape sequence: {0}", escape.Sequence)); index1 += escape.BytesInCurrentBuffer; } else if (escape.Sequence == EscapeSequence.NotRecognized) { for (var index2 = 0; index2 < escape.BytesInCurrentBuffer && index2 < lengthIn; ++index2) { if (num1 < offsetOut + lengthOut) { dataOut[num1++] = dataIn[index1 + index2]; ++num2; } } index1 += escape.BytesInCurrentBuffer; } else if (escape.Sequence == EscapeSequence.Incomplete) index1 += escape.BytesInCurrentBuffer; while (index1 < offsetIn + lengthIn) { this.CheckLoopCount(ref count, limit); var num3 = dataIn[index1]; if (num3 != 27 && num3 != 15 && (num3 != 14 && num3 != 0)) { if (num3 == 160) { if (num1 + 1 <= offsetOut + lengthOut) { dataOut[num1++] = 32; ++index1; ++num2; } else break; } else if ((num3 >= 129 && num3 <= 159 || num3 >= 224 && num3 <= 252) && (index1 + 2 <= offsetIn + lengthIn && num1 + 2 <= offsetOut + lengthOut)) { var numArray1 = dataOut; var index2 = num1; var num4 = 1; var num5 = index2 + num4; int num6 = dataIn[index1++]; numArray1[index2] = (byte) num6; ++num2; if (dataIn[index1] != 0) { var numArray2 = dataOut; var index3 = num5; var num7 = 1; num1 = index3 + num7; int num8 = dataIn[index1++]; numArray2[index3] = (byte) num8; ++num2; } else break; } else if (num1 + 1 <= offsetOut + lengthOut) { dataOut[num1++] = dataIn[index1++]; ++num2; } else break; } else break; } usedIn = index1 - offsetIn; usedOut = num2; complete = index1 == offsetIn + lengthIn; }
public abstract bool IsEscapeSequenceHandled(Escape escape);
unsafe int CompareInternal (string s1, int idx1, int len1, string s2, int idx2, int len2, out bool targetConsumed, out bool sourceConsumed, bool skipHeadingExtenders, bool immediateBreakup, ref Context ctx) { COpt opt = ctx.Option; int start1 = idx1; int start2 = idx2; int end1 = idx1 + len1; int end2 = idx2 + len2; targetConsumed = false; sourceConsumed = false; PreviousInfo prev2 = new PreviousInfo (false); if (opt == CompareOptions.None && ctx.QuickCheckPossible) return CompareQuick (s1, idx1, len1, s2, idx2, len2, out sourceConsumed, out targetConsumed, immediateBreakup); // It holds final result that comes from the comparison // at level 2 or lower. Even if Compare() found the // difference at level 2 or lower, it still has to // continue level 1 comparison. FinalResult is used // when there was no further differences. int finalResult = 0; // It holds the comparison level to do. It starts from // 5, and becomes 1 when we do primary-only comparison. int currentLevel = 5; int lv5At1 = -1; int lv5At2 = -1; int lv5Value1 = 0; int lv5Value2 = 0; // Skip heading extenders if (skipHeadingExtenders) { for (; idx1 < end1; idx1++) if (GetExtenderType (s1 [idx1]) == ExtenderType.None) break; for (; idx2 < end2; idx2++) if (GetExtenderType (s2 [idx2]) == ExtenderType.None) break; } ExtenderType ext1 = ExtenderType.None; ExtenderType ext2 = ExtenderType.None; int quickCheckPos1 = idx1; int quickCheckPos2 = idx2; bool stringSort = (opt & COpt.StringSort) != 0; bool ignoreNonSpace = (opt & COpt.IgnoreNonSpace) != 0; Escape escape1 = new Escape (); Escape escape2 = new Escape (); while (true) { for (; idx1 < end1; idx1++) if (!IsIgnorable (s1 [idx1], opt)) break; for (; idx2 < end2; idx2++) if (!IsIgnorable (s2 [idx2], opt)) break; if (idx1 >= end1) { if (escape1.Source == null) break; s1 = escape1.Source; start1 = escape1.Start; idx1 = escape1.Index; end1 = escape1.End; quickCheckPos1 = escape1.Optional; escape1.Source = null; continue; } if (idx2 >= end2) { if (escape2.Source == null) break; s2 = escape2.Source; start2 = escape2.Start; idx2 = escape2.Index; end2 = escape2.End; quickCheckPos2 = escape2.Optional; escape2.Source = null; continue; } #if true // If comparison is unstable, then this part is one of the most doubtful part. // Here we run quick codepoint comparison and run back to "stable" area to // compare characters. // Strictly to say, even the first character // could be compared here, but it messed // backward step, so I just avoided mess. if (quickCheckPos1 < idx1 && quickCheckPos2 < idx2) { while (idx1 < end1 && idx2 < end2 && s1 [idx1] == s2 [idx2]) { idx1++; idx2++; } if (idx1 == end1 || idx2 == end2) continue; // check replacement int backwardEnd1 = quickCheckPos1; int backwardEnd2 = quickCheckPos2; quickCheckPos1 = idx1; quickCheckPos2 = idx2; idx1--; idx2--; for (;idx1 > backwardEnd1; idx1--) if (Category (s1 [idx1]) != 1) break; for (;idx2 > backwardEnd2; idx2--) if (Category (s2 [idx2]) != 1) break; for (;idx1 > backwardEnd1; idx1--) if (IsSafe (s1 [idx1])) break; for (;idx2 > backwardEnd2; idx2--) if (IsSafe (s2 [idx2])) break; } #endif int cur1 = idx1; int cur2 = idx2; byte* sk1 = null; byte* sk2 = null; int i1 = FilterOptions (s1 [idx1], opt); int i2 = FilterOptions (s2 [idx2], opt); bool special1 = false; bool special2 = false; // If current character is an expander, then // repeat the previous character. ext1 = GetExtenderType (i1); if (ext1 != ExtenderType.None) { if (ctx.PrevCode < 0) { if (ctx.PrevSortKey == null) { // nothing to extend idx1++; continue; } sk1 = ctx.PrevSortKey; } else i1 = FilterExtender (ctx.PrevCode, ext1, opt); } ext2 = GetExtenderType (i2); if (ext2 != ExtenderType.None) { if (prev2.Code < 0) { if (prev2.SortKey == null) { // nothing to extend idx2++; continue; } sk2 = prev2.SortKey; } else i2 = FilterExtender (prev2.Code, ext2, opt); } byte cat1 = Category (i1); byte cat2 = Category (i2); // Handle special weight characters if (cat1 == 6) { if (!stringSort && currentLevel == 5) { lv5At1 = escape1.Source != null ? escape1.Index - escape1.Start : cur1 - start1; // here Windows has a bug that it does // not consider thirtiary weight. lv5Value1 = Level1 (i1) << 8 + Uni.Level3 (i1); } ctx.PrevCode = i1; idx1++; } if (cat2 == 6) { if (!stringSort && currentLevel == 5) { lv5At2 = escape2.Source != null ? escape2.Index - escape2.Start : cur2 - start2; // here Windows has a bug that it does // not consider thirtiary weight. lv5Value2 = Level1 (i2) << 8 + Uni.Level3 (i2); } prev2.Code = i2; idx2++; } if (cat1 == 6 || cat2 == 6) { if (currentLevel == 5) { if (lv5Value1 == lv5Value2) { // There is not really difference here. lv5At1 = lv5At2 = -1; lv5Value1 = lv5Value2 = 0; } else currentLevel = 4; } continue; } Contraction ct1 = null; if (ext1 == ExtenderType.None) ct1 = GetContraction (s1, idx1, end1); int offset1 = 1; if (sk1 != null) offset1 = 1; else if (ct1 != null) { offset1 = ct1.Source.Length; if (ct1.SortKey != null) { sk1 = ctx.Buffer1; for (int i = 0; i < ct1.SortKey.Length; i++) sk1 [i] = ct1.SortKey [i]; ctx.PrevCode = -1; ctx.PrevSortKey = sk1; } else if (escape1.Source == null) { escape1.Source = s1; escape1.Start = start1; escape1.Index = cur1 + ct1.Source.Length; escape1.End = end1; escape1.Optional = quickCheckPos1; s1 = ct1.Replacement; idx1 = 0; start1 = 0; end1 = s1.Length; quickCheckPos1 = 0; continue; } } else { sk1 = ctx.Buffer1; sk1 [0] = cat1; sk1 [1] = Level1 (i1); if (!ignoreNonSpace && currentLevel > 1) sk1 [2] = Level2 (i1, ext1); if (currentLevel > 2) sk1 [3] = Uni.Level3 (i1); if (currentLevel > 3) special1 = Uni.HasSpecialWeight ((char) i1); if (cat1 > 1) ctx.PrevCode = i1; } Contraction ct2 = null; if (ext2 == ExtenderType.None) ct2 = GetContraction (s2, idx2, end2); if (sk2 != null) idx2++; else if (ct2 != null) { idx2 += ct2.Source.Length; if (ct2.SortKey != null) { sk2 = ctx.Buffer2; for (int i = 0; i < ct2.SortKey.Length; i++) sk2 [i] = ct2.SortKey [i]; prev2.Code = -1; prev2.SortKey = sk2; } else if (escape2.Source == null) { escape2.Source = s2; escape2.Start = start2; escape2.Index = cur2 + ct2.Source.Length; escape2.End = end2; escape2.Optional = quickCheckPos2; s2 = ct2.Replacement; idx2 = 0; start2 = 0; end2 = s2.Length; quickCheckPos2 = 0; continue; } } else { sk2 = ctx.Buffer2; sk2 [0] = cat2; sk2 [1] = Level1 (i2); if (!ignoreNonSpace && currentLevel > 1) sk2 [2] = Level2 (i2, ext2); if (currentLevel > 2) sk2 [3] = Uni.Level3 (i2); if (currentLevel > 3) special2 = Uni.HasSpecialWeight ((char) i2); if (cat2 > 1) prev2.Code = i2; idx2++; } // Add offset here so that it does not skip // idx1 while s2 has a replacement. idx1 += offset1; if (!ignoreNonSpace) { // add diacritical marks in s1 here while (idx1 < end1) { if (Category (s1 [idx1]) != 1) break; if (sk1 [2] == 0) sk1 [2] = 2; sk1 [2] = (byte) (sk1 [2] + Level2 (s1 [idx1], ExtenderType.None)); idx1++; } // add diacritical marks in s2 here while (idx2 < end2) { if (Category (s2 [idx2]) != 1) break; if (sk2 [2] == 0) sk2 [2] = 2; sk2 [2] = (byte) (sk2 [2] + Level2 (s2 [idx2], ExtenderType.None)); idx2++; } } int ret = sk1 [0] - sk2 [0]; ret = ret != 0 ? ret : sk1 [1] - sk2 [1]; if (ret != 0) return ret; if (currentLevel == 1) continue; if (!ignoreNonSpace) { ret = sk1 [2] - sk2 [2]; if (ret != 0) { finalResult = ret; if (immediateBreakup) return -1; // different currentLevel = frenchSort ? 2 : 1; continue; } } if (currentLevel == 2) continue; ret = sk1 [3] - sk2 [3]; if (ret != 0) { finalResult = ret; if (immediateBreakup) return -1; // different currentLevel = 2; continue; } if (currentLevel == 3) continue; if (special1 != special2) { if (immediateBreakup) return -1; // different finalResult = special1 ? 1 : -1; currentLevel = 3; continue; } if (special1) { ret = CompareFlagPair ( !Uni.IsJapaneseSmallLetter ((char) i1), !Uni.IsJapaneseSmallLetter ((char) i2)); ret = ret != 0 ? ret : ToDashTypeValue (ext1, opt) - ToDashTypeValue (ext2, opt); ret = ret != 0 ? ret : CompareFlagPair ( Uni.IsHiragana ((char) i1), Uni.IsHiragana ((char) i2)); ret = ret != 0 ? ret : CompareFlagPair ( !IsHalfKana ((char) i1, opt), !IsHalfKana ((char) i2, opt)); if (ret != 0) { if (immediateBreakup) return -1; // different finalResult = ret; currentLevel = 3; continue; } } } // If there were only level 3 or lower differences, // then we still have to find diacritical differences // if any. if (!ignoreNonSpace && finalResult != 0 && currentLevel > 2) { while (idx1 < end1 && idx2 < end2) { if (!Uni.IsIgnorableNonSpacing (s1 [idx1])) break; if (!Uni.IsIgnorableNonSpacing (s2 [idx2])) break; finalResult = Level2 (FilterOptions (s1 [idx1], opt), ext1) - Level2 (FilterOptions (s2 [idx2], opt), ext2); if (finalResult != 0) break; idx1++; idx2++; // they should work only for the first character ext1 = ExtenderType.None; ext2 = ExtenderType.None; } } if (currentLevel == 1 && finalResult != 0) { while (idx1 < end1) { if (Uni.IsIgnorableNonSpacing (s1 [idx1])) idx1++; else break; } while (idx2 < end2) { if (Uni.IsIgnorableNonSpacing (s2 [idx2])) idx2++; else break; } } // we still have to check level 5 if (finalResult == 0) { if (lv5At1 < 0 && lv5At2 >= 0) finalResult = -1; else if (lv5At2 < 0 && lv5At1 >= 0) finalResult = 1; else { finalResult = lv5At1 - lv5At2; if (finalResult == 0) finalResult = lv5Value1 - lv5Value2; } } if (finalResult == 0) { if (idx2 == end2) targetConsumed = true; if (idx1 == end1) sourceConsumed = true; } return idx1 != end1 ? 1 : idx2 == end2 ? finalResult : -1; }
public override ValidationResult GetRunLength(byte[] dataIn, int offsetIn, int lengthIn, Escape escape, out int usedIn, out int usedOut) { usedIn = 0; usedOut = 0; var flag1 = false; var flag2 = false; var index = offsetIn; var num1 = 0; var count = 0; var limit = this.CalculateLoopCountLimit(lengthIn); byte num2 = 0; if (escape.IsValidEscapeSequence) { if (!this.IsEscapeSequenceHandled(escape)) throw new System.InvalidOperationException(string.Format("unhandled escape sequence: {0}", escape.Sequence)); index += escape.BytesInCurrentBuffer; runBeganWithEscape = true; isKana = false; leftoverByte = 0; } while (index < offsetIn + lengthIn) { this.CheckLoopCount(ref count, limit); uint high; uint low; int num3; if (leftoverByte != 0 && index == offsetIn) { high = leftoverByte; low = dataIn[index]; num3 = 1; num2 = leftoverByte; leftoverByte = 0; } else if (index + 2 <= offsetIn + lengthIn) { high = dataIn[index]; low = dataIn[index + 1]; num3 = 2; } else { uint num4 = dataIn[index]; if ((int) num4 == 27 || !runBeganWithEscape && ((int) num4 == 14 || (int) num4 == 15) || (int) num4 == 0) { flag2 = true; break; } if (isKana && (int) num4 != 14 && (int) num4 != 15) { ++index; ++num1; } break; } if ((int) high == 27) { flag2 = true; break; } if ((int) high == 0) { flag2 = true; break; } if ((int) low == 27) { if ((int) high == 14 || (int) high == 15) { if (runBeganWithEscape) ++index; } else { ++index; if (isKana) ++num1; } flag2 = true; break; } if ((int) low == 0) { if ((int) high == 14 || (int) high == 15) { if (runBeganWithEscape) ++index; } else { ++index; if (isKana) ++num1; } flag2 = true; break; } if (!runBeganWithEscape) { if ((int) high == 14 || (int) high == 15 || ((int) low == 14 || (int) low == 15)) { flag2 = true; break; } } else { if ((int) high == 14) { isKana = true; index += num3; if ((int) low != 14 && (int) low != 15) ++num1; continue; } if ((int) high == 15) { isKana = false; index += num3 - 1; continue; } if ((int) low == 14) { index += num3; ++num1; isKana = true; continue; } if ((int) low == 15) { isKana = false; index += num3; ++num1; continue; } } if (high >= 128U) { flag1 = true; if (runBeganWithEscape) { if (isRunContainsIbmExtension == JisX0208PairClass.Unrecognized && this.ClassifyPair(high, low) == JisX0208PairClass.IbmExtension) isRunContainsIbmExtension = JisX0208PairClass.IbmExtension; } else break; } index += num3; num1 += 2; } if (!flag2 && index + 1 == offsetIn + lengthIn) ++index; usedIn = index - offsetIn; usedOut = num1; if (num2 != 0) leftoverByte = num2; return !flag1 || runBeganWithEscape ? ValidationResult.Valid : ValidationResult.Invalid; }
// public override ValidationResult GetRunLength(byte[] dataIn, int offsetIn, int lengthIn, Escape escape, out int usedIn, out int usedOut) // { // usedIn = 0; // usedOut = 0; // int index = offsetIn; // int num = 0; // int count = 0; // int limit = this.CalculateLoopCountLimit(lengthIn); // if (escape.IsValidEscapeSequence) // { // if (!this.IsEscapeSequenceHandled(escape)) // throw new InvalidOperationException(string.Format("unhandled escape sequence: {0}", (object) escape.Sequence)); // index += escape.BytesInCurrentBuffer; // this.runBeganWithEscape = true; // goto case (byte) 14; // } // else // { // if (!this.runBeganWithEscape) // return ValidationResult.Invalid; // goto case (byte) 14; // } // for (; index < offsetIn + lengthIn; ++index) // { // this.CheckLoopCount(ref count, limit); // switch (dataIn[index]) // { // case (byte) 27: // case (byte) 0: // goto label_10; // case (byte) 14: // case (byte) 15: // goto case (byte) 14; // default: // ++num; // goto case (byte) 14; // } // } //label_10: // usedIn = index - offsetIn; // usedOut = num; // return ValidationResult.Valid; // } public override ValidationResult GetRunLength(byte[] dataIn, int offsetIn, int lengthIn, Escape escape, out int usedIn, out int usedOut) { usedIn = 0; usedOut = 0; var index = offsetIn; var num2 = 0; var count = 0; var limit = this.CalculateLoopCountLimit(lengthIn); if (escape.IsValidEscapeSequence) { if (!this.IsEscapeSequenceHandled(escape)) throw new System.InvalidOperationException(string.Format("unhandled escape sequence: {0}", escape.Sequence)); index += escape.BytesInCurrentBuffer; runBeganWithEscape = true; } else if (!runBeganWithEscape) return ValidationResult.Invalid; while (index < (offsetIn + lengthIn)) { this.CheckLoopCount(ref count, limit); var num5 = dataIn[index]; switch (num5) { case 0x1b: case 0: goto Label_0094; } if ((num5 != 14) && (num5 != 15)) num2++; index++; } Label_0094: usedIn = index - offsetIn; usedOut = num2; return ValidationResult.Valid; }
public override bool IsEscapeSequenceHandled(Escape escape) { if (escape.Sequence != EscapeSequence.JisX0201_1976 && escape.Sequence != EscapeSequence.JisX0201K_1976 && escape.Sequence != EscapeSequence.ShiftIn) return escape.Sequence == EscapeSequence.ShiftOut; return true; }
public abstract void ConvertToCp932(byte[] dataIn, int offsetIn, int lengthIn, byte[] dataOut, int offsetOut, int lengthOut, bool flush, Escape escape, out int usedIn, out int usedOut, out bool complete);
public static void MapEscape(byte[] dataIn, int offsetIn, int lengthIn, Escape escape) { var num1 = 0; var state = escape.State; var num2 = offsetIn; while (lengthIn > 0) { var num3 = dataIn[offsetIn]; EscapeSequence escapeSequence; switch (escape.State) { case EscapeState.Begin: if (num3 == 27) { escape.State = EscapeState.Esc_1; break; } if (num3 == 14) { escapeSequence = EscapeSequence.ShiftOut; goto label_83; } if (num3 == 15) { escapeSequence = EscapeSequence.ShiftIn; goto label_83; } escape.BytesInCurrentBuffer = 0; escape.TotalBytes = 0; escape.Sequence = EscapeSequence.None; return; case EscapeState.Esc_1: if (num3 == 36) { escape.State = EscapeState.Esc_Dollar_2; break; } if (num3 == 40) { escape.State = EscapeState.Esc_OpenParen_2; break; } if (num3 == 72) { escapeSequence = EscapeSequence.NECKanjiIn; goto label_83; } if (num3 == 75) { escapeSequence = EscapeSequence.JisX0208_Nec; goto label_83; } if (num3 == 38) { escape.State = EscapeState.Esc_Ampersand_2; break; } if (num3 != 27) { if (num3 != 14 && num3 != 15) { if (num3 != 0) goto label_84; goto label_84; } goto case 12; } goto case 11; case EscapeState.Esc_Dollar_2: if (num3 == 64) { escapeSequence = EscapeSequence.JisX0208_1983; goto label_83; } if (num3 == 65) { escapeSequence = EscapeSequence.Gb2312_1980; goto label_83; } if (num3 == 66) { escapeSequence = EscapeSequence.JisX0208_1978; goto label_83; } if (num3 == 40) { escape.State = EscapeState.Esc_Dollar_OpenParen_3; break; } if (num3 == 41) { escape.State = EscapeState.Esc_Dollar_CloseParen_3; break; } if (num3 != 27) { if (num3 == 14 || num3 == 15) goto case 12; goto label_84; } goto case 11; case EscapeState.Esc_OpenParen_2: if (num3 == 73) { escapeSequence = EscapeSequence.JisX0201K_1976; goto label_83; } if (num3 == 74) { escapeSequence = EscapeSequence.JisX0201_1976; goto label_83; } if (num3 == 68) { escapeSequence = EscapeSequence.JisX0212_1990; goto label_83; } if (num3 == 66) { escapeSequence = EscapeSequence.Iso646Irv; goto label_83; } if (num3 != 27) { if (num3 == 14 || num3 == 15) goto case 12; goto label_84; } goto case 11; case EscapeState.Esc_Ampersand_2: if (num3 == 64) { escape.State = EscapeState.Esc_Ampersand_At_3; break; } if (num3 != 27) { if (num3 == 14 || num3 == 15) goto case 12; goto label_84; } goto case 11; case EscapeState.Esc_Dollar_OpenParen_3: if (num3 == 71) { escapeSequence = EscapeSequence.Cns11643_1992_1; goto label_83; } if (num3 == 67) { escapeSequence = EscapeSequence.Kcs5601_1987; goto label_83; } if (num3 == 72) { escapeSequence = EscapeSequence.Cns11643_1992_1; goto label_83; } if (num3 == 81) { escapeSequence = EscapeSequence.Unknown_1; goto label_83; } if (num3 != 27) { if (num3 == 14 || num3 == 15) goto case 12; goto label_84; } goto case 11; case EscapeState.Esc_Dollar_CloseParen_3: if (num3 == 67) { escapeSequence = EscapeSequence.EucKsc; goto label_83; } if (num3 != 27) { if (num3 == 14 || num3 == 15) goto case 12; goto label_84; } goto case 11; case EscapeState.Esc_Ampersand_At_3: if (num3 == 27) { escape.State = EscapeState.Esc_Ampersand_At_Esc_4; break; } if (num3 == 14 || num3 == 15) goto case 12; goto label_84; case EscapeState.Esc_Ampersand_At_Esc_4: if (num3 == 36) { escape.State = EscapeState.Esc_Ampersand_At_Esc_Dollar_5; break; } if (num3 != 27) { if (num3 == 14 || num3 == 15) goto case 12; goto label_84; } goto case 11; case EscapeState.Esc_Ampersand_At_Esc_Dollar_5: if (num3 == 66) { escapeSequence = EscapeSequence.JisX0208_1990; goto label_83; } if (num3 != 27) { if (num3 == 14 || num3 == 15) goto case 12; goto label_84; } goto case 11; case EscapeState.Esc_Esc_Reset: escape.State = EscapeState.Esc_1; break; case EscapeState.Esc_SISO_Reset: if (num3 == 14) { escapeSequence = EscapeSequence.ShiftOut; goto label_83; } if (num3 != 15) throw new System.InvalidOperationException(string.Format("MapEscape: at Esc_SISO_Reset with {0}", (int) num3)); escapeSequence = EscapeSequence.ShiftIn; goto label_83; default: throw new System.InvalidOperationException("MapEscape: unrecognized state!"); } --lengthIn; ++offsetIn; ++num1; continue; label_83: escape.BytesInCurrentBuffer = num1 + 1; escape.TotalBytes += escape.BytesInCurrentBuffer; escape.State = EscapeState.Begin; escape.Sequence = escapeSequence; return; label_84: var str = string.Empty; while (num2 <= offsetIn && num2 < offsetIn + lengthIn) str += dataIn[num2++].ToString("X2"); string.Format("Unrecognized escape sequence {0}, initial state {1}, current state {2}", str, state, escape.State); escape.State = EscapeState.Begin; escape.Sequence = EscapeSequence.NotRecognized; escape.BytesInCurrentBuffer = num1; escape.TotalBytes += num1; return; } escape.BytesInCurrentBuffer = num1; escape.TotalBytes += escape.BytesInCurrentBuffer; escape.Sequence = EscapeSequence.Incomplete; }
public override void ConvertToCp932(byte[] dataIn, int offsetIn, int lengthIn, byte[] dataOut, int offsetOut, int lengthOut, bool flush, Escape escape, out int usedIn, out int usedOut, out bool complete) { usedIn = 0; usedOut = 0; complete = false; var flag = false; var index1 = offsetIn; var index2 = offsetOut; var num1 = 0; var count = 0; var limit = this.CalculateLoopCountLimit(lengthIn); if (escape.IsValidEscapeSequence) { if (!this.IsEscapeSequenceHandled(escape)) throw new System.InvalidOperationException(string.Format("unhandled escape sequence: {0}", escape.Sequence)); index1 += escape.BytesInCurrentBuffer; isKana = false; leftoverByte = 0; } while (index1 < offsetIn + lengthIn) { this.CheckLoopCount(ref count, limit); uint num2; uint num3; int num4; int num5; if (leftoverByte != 0) { if (index1 != offsetIn) throw new System.InvalidOperationException(string.Format("DecodeJisX0208_1983ToCp932.ConvertToCp932: leftover byte processed at offset {0}, should have been {1}", index1, offsetIn)); num2 = leftoverByte; num3 = dataIn[index1]; num4 = 1; leftoverByte = 0; } else if (index1 + 2 <= offsetIn + lengthIn) { num2 = dataIn[index1]; num3 = dataIn[index1 + 1]; num4 = 2; } else { uint current = dataIn[index1]; if ((int) current == 27 || !runBeganWithEscape && ((int) current == 14 || (int) current == 15) || (int) current == 0) { flag = true; break; } if (isKana && (int) current != 14 && (int) current != 15) { var numArray = dataOut; var index3 = index2; var num6 = 1; num5 = index3 + num6; int num7 = this.DecodeKana(current); numArray[index3] = (byte) num7; ++num1; ++index1; } break; } if ((int) num2 == 27) { runBeganWithEscape = false; flag = true; break; } if ((int) num2 == 0) { flag = true; break; } if ((int) num3 == 27) { runBeganWithEscape = false; flag = true; ++index1; if (isKana && (int) num2 != 14) { if ((int) num2 == 15) { isKana = false; break; } var numArray = dataOut; var index3 = index2; var num6 = 1; num5 = index3 + num6; int num7 = this.DecodeKana(num2); numArray[index3] = (byte) num7; ++num1; } break; } if ((int) num3 == 0) { flag = true; ++index1; if (isKana && (int) num2 != 14) { if ((int) num2 == 15) { isKana = false; break; } var numArray = dataOut; var index3 = index2; var num6 = 1; num5 = index3 + num6; int num7 = this.DecodeKana(num2); numArray[index3] = (byte) num7; ++num1; } break; } if (!runBeganWithEscape) { if ((int) num2 == 14 || (int) num2 == 15 || ((int) num3 == 14 || (int) num3 == 15)) { flag = true; break; } } else if ((int) num2 == 14) { isKana = true; index1 += num4; switch (num3) { case 14U: continue; case 15U: isKana = false; continue; default: dataOut[index2++] = this.DecodeKana(num3); ++num1; continue; } } else { if ((int) num2 == 15) { isKana = false; index1 += num4 - 1; continue; } if ((int) num3 == 14) { index1 += num4; dataOut[index2] = isKana ? this.DecodeKana(num2) : (byte) 165; ++index2; ++num1; isKana = true; continue; } if ((int) num3 == 15) { dataOut[index2] = isKana ? this.DecodeKana(num2) : (byte) 165; index1 += num4; ++num1; ++index2; isKana = false; continue; } } if (index2 + 2 <= offsetOut + lengthOut) { if (isKana) { dataOut[index2] = this.DecodeKana(num2); dataOut[index2 + 1] = this.DecodeKana(num3); } else if (num2 >= 128U) { switch (this.ClassifyPair(num2, num3)) { case JisX0208PairClass.Unrecognized: case JisX0208PairClass.Cp932: dataOut[index2] = (byte) num2; dataOut[index2 + 1] = (byte) num3; break; case JisX0208PairClass.IbmExtension: isRunContainsIbmExtension = JisX0208PairClass.IbmExtension; byte highOut; byte lowOut; this.MapIbmExtensionToCp932(num2, num3, out highOut, out lowOut); dataOut[index2] = highOut; dataOut[index2 + 1] = lowOut; break; case JisX0208PairClass.IbmExtension | JisX0208PairClass.Cp932: if (isRunContainsIbmExtension != JisX0208PairClass.IbmExtension) goto case JisX0208PairClass.Unrecognized; goto case JisX0208PairClass.IbmExtension; default: throw new System.InvalidOperationException("unrecognized pair class, update DecodeJisX0208_1983.DecodeToCp932"); } } else { var num6 = ((int) num2 & 1) != 1 ? num3 + 125U : num3 + 31U; if (num6 >= (uint) sbyte.MaxValue) ++num6; var num7 = (num2 - 33U >> 1) + 129U; if (num7 > 159U) num7 += 64U; dataOut[index2] = (byte) num7; dataOut[index2 + 1] = (byte) num6; } index1 += num4; index2 += 2; num1 += 2; } else break; } if (!flag && index1 + 1 == offsetIn + lengthIn) leftoverByte = dataIn[index1++]; usedIn = index1 - offsetIn; usedOut = num1; complete = index1 == offsetIn + lengthIn; }
public abstract ValidationResult GetRunLength(byte[] dataIn, int offsetIn, int lengthIn, Escape escape, out int bytesConsumed, out int bytesProduced);