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 namespace UglyToad.PdfPig.Core
{ {
using System.Diagnostics; using System.Diagnostics;
using System.Globalization;
/// <summary> /// <summary>
/// A point in a PDF file. /// A point in a PDF file.
@@ -112,7 +113,7 @@
/// <inheritdoc /> /// <inheritdoc />
public override string ToString() 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 namespace UglyToad.PdfPig.Core
{ {
using System; using System;
using System.Globalization;
/// <summary> /// <summary>
/// A rectangle in a PDF file. /// A rectangle in a PDF file.
@@ -208,7 +209,7 @@
/// <inheritdoc /> /// <inheritdoc />
public override string ToString() 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.Text; using System.Text;
using Core; using Core;
@@ -184,7 +185,7 @@
if (i >= 0) if (i >= 0)
{ {
var value = Values[i]; var value = Values[i];
stringBuilder.AppendLine(value.ToString("N")); stringBuilder.AppendLine(value.ToString("N", CultureInfo.InvariantCulture));
} }
foreach (var identifier in GetCommandsAt(i + 1)) foreach (var identifier in GetCommandsAt(i + 1))

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,11 +1,12 @@
namespace UglyToad.PdfPig.PdfFonts namespace UglyToad.PdfPig.PdfFonts
{ {
using System.Globalization;
using CidFonts; using CidFonts;
/// <summary> /// <summary>
/// Specifies the character collection associated with the <see cref="ICidFont"/> (CIDFont). /// Specifies the character collection associated with the <see cref="ICidFont"/> (CIDFont).
/// </summary> /// </summary>
internal struct CharacterIdentifierSystemInfo internal readonly struct CharacterIdentifierSystemInfo
{ {
/// <summary> /// <summary>
/// Identifies the issuer of the character collection. /// Identifies the issuer of the character collection.
@@ -31,7 +32,7 @@
public override string ToString() 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.Linq; using System.Linq;
using Cmap; using Cmap;
using Core; using Core;
@@ -136,7 +137,7 @@
} }
else else
{ {
glyphName = index.ToString(); glyphName = index.ToString(CultureInfo.InvariantCulture);
} }
fakeEncoding[i] = glyphName; fakeEncoding[i] = glyphName;