Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add code comments to QR code generation #517

Merged
merged 16 commits into from
May 6, 2024
Prev Previous commit
Next Next commit
Apply suggestions from code review
  • Loading branch information
Shane32 authored May 5, 2024
commit bf046941bc72b8f538c10d116d2642d125694bb1
4 changes: 2 additions & 2 deletions QRCoder/QRCodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -713,9 713,9 @@ private static int GetCountIndicatorLength(int version, EncodingMode encMode)
private static int GetDataLength(EncodingMode encoding, string plainText, BitArray codedText, bool forceUtf8)
{
// If UTF-8 is forced or the text is detected as UTF-8, return the number of bytes, otherwise return the character count.
return forceUtf8 || IsUtf8(encoding, plainText, forceUtf8) ? (int)((uint)codedText.Length / 8) : plainText.Length;
return forceUtf8 || IsUtf8() ? (int)((uint)codedText.Length / 8) : plainText.Length;

bool IsUtf8(EncodingMode encoding, string plainText, bool forceUtf8)
bool IsUtf8()
{
return (encoding == EncodingMode.Byte && (!IsValidISO(plainText) || forceUtf8));
}
Expand Down