add string culture in core code #190

This commit is contained in:
Eliot Jones
2020-07-26 13:53:34 +01:00
parent 48522ae1a5
commit f3f7533507
9 changed files with 21 additions and 14 deletions

View File

@@ -1,6 +1,7 @@
namespace UglyToad.PdfPig.Core
{
using System.Diagnostics;
using System.Globalization;
/// <summary>
/// A point in a PDF file.
@@ -112,7 +113,7 @@
/// <inheritdoc />
public override string ToString()
{
return $"(x:{X}, y:{Y})";
return $"(x:{X.ToString(CultureInfo.InvariantCulture)}, y:{Y.ToString(CultureInfo.InvariantCulture)})";
}
}
}

View File

@@ -1,6 +1,7 @@
namespace UglyToad.PdfPig.Core
{
using System;
using System.Globalization;
/// <summary>
/// A rectangle in a PDF file.
@@ -208,7 +209,7 @@
/// <inheritdoc />
public override string ToString()
{
return $"[{TopLeft}, {Width}, {Height}]";
return $"[{TopLeft}, {Width.ToString(CultureInfo.InvariantCulture)}, {Height.ToString(CultureInfo.InvariantCulture)}]";
}
}
}

View File

@@ -2,6 +2,7 @@
{
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using Core;
@@ -184,7 +185,7 @@
if (i >= 0)
{
var value = Values[i];
stringBuilder.AppendLine(value.ToString("N"));
stringBuilder.AppendLine(value.ToString("N", CultureInfo.InvariantCulture));
}
foreach (var identifier in GetCommandsAt(i + 1))

View File

@@ -2,6 +2,7 @@
{
using System;
using System.Collections.Generic;
using System.Globalization;
internal class Type1CharstringDecryptedBytes
{
@@ -25,7 +26,7 @@
{
Bytes = bytes ?? throw new ArgumentNullException(nameof(bytes));
Index = index;
Name = name ?? index.ToString();
Name = name ?? index.ToString(CultureInfo.InvariantCulture);
Source = SourceType.Charstring;
}

View File

@@ -1,6 +1,7 @@
namespace UglyToad.PdfPig.Tests.Tokenization
{
using System.Collections.Generic;
using System.Threading;
using PdfPig.Tokenization;
using PdfPig.Tokens;
using Xunit;
@@ -17,6 +18,7 @@
[InlineData("\0")]
public void InvalidFirstCharacter_ReturnsFalse(string s)
{
var cult = Thread.CurrentThread.CurrentCulture;
var input = StringBytesTestConverter.Convert(s);
var result = tokenizer.TryTokenize(input.First, input.Bytes, out var token);

View File

@@ -1,14 +1,12 @@
namespace UglyToad.PdfPig.Content
{
using System;
using System.Diagnostics.Contracts;
using Core;
using Geometry;
using System.Globalization;
/// <summary>
/// Represents the rotation of a page in a PDF document defined by the page dictionary in degrees clockwise.
/// </summary>
public struct PageRotationDegrees : IEquatable<PageRotationDegrees>
public readonly struct PageRotationDegrees : IEquatable<PageRotationDegrees>
{
/// <summary>
/// The rotation of the page in degrees clockwise.
@@ -76,7 +74,7 @@
/// <inheritdoc />
public override string ToString()
{
return Value.ToString();
return Value.ToString(CultureInfo.InvariantCulture);
}
/// <inheritdoc />

View File

@@ -1,12 +1,13 @@
namespace UglyToad.PdfPig.Geometry
{
using System;
using System.Globalization;
/// <summary>
/// By default user space units correspond to 1/72nd of an inch (a typographic point).
/// The UserUnit entry in a page dictionary can define the space units as a different multiple of 1/72 (1 point).
/// </summary>
internal struct UserSpaceUnit
internal readonly struct UserSpaceUnit
{
public static readonly UserSpaceUnit Default = new UserSpaceUnit(1);
@@ -30,7 +31,7 @@
public override string ToString()
{
return PointMultiples.ToString();
return PointMultiples.ToString(CultureInfo.InvariantCulture);
}
}
}

View File

@@ -1,11 +1,12 @@
namespace UglyToad.PdfPig.PdfFonts
{
using System.Globalization;
using CidFonts;
/// <summary>
/// Specifies the character collection associated with the <see cref="ICidFont"/> (CIDFont).
/// </summary>
internal struct CharacterIdentifierSystemInfo
internal readonly struct CharacterIdentifierSystemInfo
{
/// <summary>
/// Identifies the issuer of the character collection.
@@ -31,7 +32,7 @@
public override string ToString()
{
return $"{Registry}-{Ordering}-{Supplement}";
return $"{Registry}-{Ordering}-{Supplement.ToString(CultureInfo.InvariantCulture)}";
}
}
}

View File

@@ -2,6 +2,7 @@
{
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Cmap;
using Core;
@@ -136,7 +137,7 @@
}
else
{
glyphName = index.ToString();
glyphName = index.ToString(CultureInfo.InvariantCulture);
}
fakeEncoding[i] = glyphName;