Skip to content

Commit

Permalink
Updates based on code review
Browse files Browse the repository at this point in the history
  • Loading branch information
Shane32 committed Apr 26, 2024
1 parent 069e4a1 commit 97d1ce5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
8 changes: 4 additions & 4 deletions QRCoder/PayloadGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2516,8 +2516,8 @@ public override string ToString()
var cp = characterSet.ToString().Replace("_", "-");
var bytes = ToBytes();

#if NETCOREAPP
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
#if !NETFRAMEWORK
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
#endif
return Encoding.GetEncoding(cp).GetString(bytes, 0, bytes.Length);
}
Expand All @@ -2532,7 +2532,7 @@ public byte[] ToBytes()
{
//Setup byte encoder
//Encode return string as byte[] with correct CharacterSet
#if !NETFRAMEWORK // -- why different ifdef than line 2519? --
#if !NETFRAMEWORK
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
#endif
var cp = this.characterSet.ToString().Replace("_", "-");
Expand Down Expand Up @@ -3111,7 +3111,7 @@ private static string ConvertStringToEncoding(string message, string encoding)
Encoding utf8 = Encoding.UTF8;
byte[] utfBytes = utf8.GetBytes(message);
byte[] isoBytes = Encoding.Convert(utf8, iso, utfBytes);
return iso.GetString(isoBytes, 0, isoBytes.Length);
return iso.GetString(isoBytes);
}

private static string EscapeInput(string inp, bool simple = false)
Expand Down
3 changes: 1 addition & 2 deletions QRCoder/QRCodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1026,8 +1026,7 @@ private static bool IsUtf8(EncodingMode encoding, string plainText, bool forceUt
private static bool IsValidISO(string input)
{
var bytes = Encoding.GetEncoding("ISO-8859-1").GetBytes(input);
//var result = Encoding.GetEncoding("ISO-8859-1").GetString(bytes);
var result = Encoding.GetEncoding("ISO-8859-1").GetString(bytes,0,bytes.Length);
var result = Encoding.GetEncoding("ISO-8859-1").GetString(bytes);
return String.Equals(input, result);
}

Expand Down

0 comments on commit 97d1ce5

Please sign in to comment.