Skip to content

Commit

Permalink
Compose hex sequences start with \0x, not \x. Reported in #329.
Browse files Browse the repository at this point in the history
  • Loading branch information
samhocevar committed Mar 23, 2020
1 parent 7e83b13 commit 808cc70
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/sequences/SequenceTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,15 @@ private void ParseRule(string line)
{
result = result.Trim('"');
// Unescape \n \\ \" and more in the string output
result = Regex.Replace(result, @"\\([0-7]{3}|x[0-7a-fA-F]{4}|.)", m =>
result = Regex.Replace(result, @"\\([0-7]{3}|0x[0-7a-fA-F]{4}|.)", m =>
{
var s = m.Value;

if (s.Length == 4) // Octal escape
return ((char)Convert.ToInt32(s.Substring(1), 8)).ToString();

if (s.Length == 6) // Hex escape
return ((char)Convert.ToInt32(s.Substring(2), 16)).ToString();
if (s.Length == 7) // Hex escape
return ((char)Convert.ToInt32(s.Substring(3), 16)).ToString();

switch (s[1])
{
Expand Down

0 comments on commit 808cc70

Please sign in to comment.