-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed #154 - Crash while parsing log
- Loading branch information
Showing
3 changed files
with
15 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,30 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text.RegularExpressions; | ||
|
||
namespace Cyanlabs.Syn3Updater.Converter | ||
{ | ||
public class SyncHexToAscii | ||
public static class SyncHexToAscii | ||
{ | ||
public static List<string> ConvertPackages( string packageHex) | ||
{ | ||
List<string> output = new(); | ||
foreach (string package in Regex.Replace(packageHex, "0*0", " ").Split(' ')) | ||
string res = string.Empty; | ||
for (int a = 0; a <packageHex.Length ; a += 2) | ||
{ | ||
string res = string.Empty ; | ||
for (int a = 0; a <package.Length ; a += 2) | ||
string char2Convert = packageHex.Substring(a, 2); | ||
if (char2Convert == "00") | ||
{ | ||
res += "_"; | ||
} | ||
else | ||
{ | ||
string char2Convert = package.Substring(a, 2); | ||
int n = Convert.ToInt32(char2Convert, 16); | ||
char c = (char)n; | ||
res += c.ToString(); | ||
} | ||
if (res != string.Empty) output.Add(res); | ||
} | ||
return output; | ||
return Regex.Replace(res, "_*_", "_").Split('_').ToList(); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters