fix: remove 0 from nest name encoding and padding
Use chars.Length instead of hardcoded 36 for modulus/division since the character set excludes 0 and O. Pad with '2' (first valid char) instead of '0' to avoid ambiguity. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -79,7 +79,7 @@ namespace OpenNest.Forms
|
|||||||
private string GetNestName(DateTime date, int id)
|
private string GetNestName(DateTime date, int id)
|
||||||
{
|
{
|
||||||
var year = (date.Year % 100).ToString("D2");
|
var year = (date.Year % 100).ToString("D2");
|
||||||
var seq = ToBase36(id).PadLeft(3, '0');
|
var seq = ToBase36(id).PadLeft(3, '2');
|
||||||
|
|
||||||
return $"N{year}-{seq}";
|
return $"N{year}-{seq}";
|
||||||
}
|
}
|
||||||
@@ -87,13 +87,13 @@ namespace OpenNest.Forms
|
|||||||
private static string ToBase36(int value)
|
private static string ToBase36(int value)
|
||||||
{
|
{
|
||||||
const string chars = "2345679ACDEFGHJKLMNPQRSTUVWXYZ";
|
const string chars = "2345679ACDEFGHJKLMNPQRSTUVWXYZ";
|
||||||
if (value == 0) return "0";
|
if (value == 0) return chars[0].ToString();
|
||||||
|
|
||||||
var result = "";
|
var result = "";
|
||||||
while (value > 0)
|
while (value > 0)
|
||||||
{
|
{
|
||||||
result = chars[value % 36] + result;
|
result = chars[value % chars.Length] + result;
|
||||||
value /= 36;
|
value /= chars.Length;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user