private char ParseURLEncoding(int c) { int ch1 = c; int ch2 = Read(); return((char)(JsParser.FromHex(ch1) << 4 | JsParser.FromHex(ch2))); }
private char ParseUnicode() { int ch1 = Read(); int ch2 = Read(); int ch3 = Read(); int ch4 = Read(); if (ch1 > -1 && ch2 > -1 && ch3 > -1 && ch4 > -1) { return((char)(JsParser.FromHex(ch1) << 12 | JsParser.FromHex(ch2) << 8 | JsParser.FromHex(ch3) << 4 | JsParser.FromHex((ch4)))); } throw new FormatException("The input contains a malformed character escape."); }
/// <summary> /// Parses a <see cref="Vlad2Net.Json.JsNumber"/> from the underlying /// stream. /// </summary> /// <returns>The parsed JsNumber.</returns> public JsNumber ParseNumber() { AssertNext(TokenType.Number); int ch; double value; StringBuilder sb = new StringBuilder(); while ((ch = Peek()) > -1 && JsParser.IsNumberComponent(ch)) { sb.Append((char)Read()); } if (double.TryParse(sb.ToString(), NumberStyles.Float, CultureInfo.InvariantCulture, out value)) { return(new JsNumber(value)); } throw new FormatException("The input contains a malformed Json-Number."); }