Skip to content

Commit fa926af

Browse files
committed
Use code page numbers
1 parent e97301b commit fa926af

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

QRCoder/QRCodeGenerator.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ bool IsUtf8()
745745
}
746746
}
747747

748-
private static readonly Encoding _iso88591ExceptionFallback = Encoding.GetEncoding("ISO-8859-1", new EncoderExceptionFallback(), new DecoderExceptionFallback());
748+
private static readonly Encoding _iso88591ExceptionFallback = Encoding.GetEncoding(28591, new EncoderExceptionFallback(), new DecoderExceptionFallback()); // ISO-8859-1
749749
/// <summary>
750750
/// Checks if the given string can be accurately represented and retrieved in ISO-8859-1 encoding.
751751
/// </summary>
@@ -877,7 +877,7 @@ private static BitArray PlainTextToBinaryAlphanumeric(string plainText)
877877
#if NET5_0_OR_GREATER
878878
Encoding.Latin1;
879879
#else
880-
Encoding.GetEncoding("ISO-8859-1");
880+
Encoding.GetEncoding(28591); // ISO-8859-1
881881
#endif
882882
private static Encoding _iso8859_2;
883883

@@ -920,7 +920,7 @@ private static BitArray PlainTextToBinaryByte(string plainText, EciMode eciMode,
920920
// Users must install the System.Text.Encoding.CodePages package and call Encoding.RegisterProvider(CodePagesEncodingProvider.Instance)
921921
// before using this encoding mode.
922922
if (_iso8859_2 == null)
923-
_iso8859_2 = Encoding.GetEncoding("ISO-8859-2");
923+
_iso8859_2 = Encoding.GetEncoding(28592); // ISO-8859-2
924924
// Convert text to ISO-8859-2 and encode.
925925
targetEncoding = _iso8859_2;
926926
utf8BOM = false;

QRCoderTests/QRGeneratorTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,9 @@ public void can_generate_from_bytes()
195195
[Category("QRGenerator/TextEncoding")]
196196
public void isValidIso_works()
197197
{
198-
Encoding _iso88591ExceptionFallback = Encoding.GetEncoding("ISO-8859-1", new EncoderExceptionFallback(), new DecoderExceptionFallback());
198+
// see private method: QRCodeGenerator.IsValidISO
199+
200+
Encoding _iso88591ExceptionFallback = Encoding.GetEncoding(28591, new EncoderExceptionFallback(), new DecoderExceptionFallback()); // ISO-8859-1
199201

200202
IsValidISO("abc").ShouldBeTrue();
201203
IsValidISO("äöü").ShouldBeTrue();

0 commit comments

Comments
 (0)