-
-
Notifications
You must be signed in to change notification settings - Fork 68
Open
Description
Hi, I am unsure of what to put here so i'll try to put as much information as i can.
Context
I'm currently using the pip library.
The problem
Using accents create an offest in the AST.
I can't stop using them because I have user feedback (not in this code, but in general in my software)
Using accents
The Csharp script
using System.Text.RegularExpressions;
namespace HUBLoader.Types;
public class TypeArret
{
private readonly string bits;
public TypeArret(string rawBits)
{
if (rawBits.Length != 20)
throw new ArgumentException($"TypeArret doit contenir exactement 20 caractères (reçu {rawBits.Length})");
if (!Regex.IsMatch(rawBits, "^[ON]{20}$", RegexOptions.IgnoreCase))
throw new ArgumentException("TypeArret ne doit contenir que des caractères 'O' ou 'N'.");
bits = rawBits.ToUpperInvariant();
}
public bool EstActif(TypeArretFlag flag)
{
return bits[(int)flag] == 'O';
}
public override string ToString()
{
return bits;
}
}
AST to JSON
Without accents
Csharp script
using System.Text.RegularExpressions;
namespace HUBLoader.Types;
public class TypeArret
{
private readonly string bits;
public TypeArret(string rawBits)
{
if (rawBits.Length != 20)
throw new ArgumentException($"TypeArret doit contenir exactement 20 caracteres (recu {rawBits.Length})");
if (!Regex.IsMatch(rawBits, "^[ON]{20}$", RegexOptions.IgnoreCase))
throw new ArgumentException("TypeArret ne doit contenir que des caracteres 'O' ou 'N'.");
bits = rawBits.ToUpperInvariant();
}
public bool EstActif(TypeArretFlag flag)
{
return bits[(int)flag] == 'O';
}
public override string ToString()
{
return bits;
}
}
AST to JSON
Metadata
Metadata
Assignees
Labels
No labels