-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
What is the purpose of forceUtf8
?
#513
Comments
Time for a little history lesson. Unfortunately, the question is not quite so easy to answer... Chapter 1 (the year is 2013)In the original implementation of the QRCoder, the Chapter 2 (the year is 2016)Unfortunately, the world is not always that simple and some QRCoder readers always expected the user data in ByteMode. If data came in ISO 8859-1 format, these readers displayed special characters incorrectly. (In my opinion, the fault lies with the readers, which do not fully map the ISO standard). Chapter 3 (the year is 2018)For mapping SlovenianUpn QR codes, it is necessary to encode QR codes in ISO 8859-2 mode. (This is a requirement from the UPN QR Form Standard) Chapter 4 (back to the here and now)As you noted @Shane32, the Long story short: The Or do you think we should make a hard cut here and remove the parameter completely? |
I want to think about it some more, but generally I'm thinking:
I'll have to think about it some more when I have additional time. |
So should I wait with merging #514 ? |
Yeah; I’ll mark it WIP. I’d rather have a consensus before we merge anything. |
Question
When generating a QR code with
QRCodeGenerator.CreateQrCode
, what is the purpose offorceUtf8
versuseciMode: EciMode.Utf8
?I would expect that specifying
EciMode.Utf8
would force the generated code to use the UTF-8 character set when encoding the data. But in fact, it does so only when either (a) there are non-ISO-8859-1 characters present, or (b)forceUtf8
istrue
.Consider the following:
A similar phenomenon occurs when specifying
EciMode.Iso8859_2
with specific strings -- interestingly,forceUtf8
must betrue
for the code to function correctly.If we assume that this is a bug, and
EciMode.Utf8
should always encode with UTF-8, then what is the purpose for theforceUtf8
argument? My best guess is that it is some compatibility mode to use UTF-8 encoding when encoded withEciMode.Default
(which normally encodes as ISO-8859-1).Suggestion
I suggest that:
EciMode
besidesEciMode.Default
, the text is always encoded in the specified encoding.EciMode.Default
withforceUtf8 == false
, it uses ISO-8859-1 (per spec,EciMode.Iso8859_1
is default)EciMode.Default
withforceUtf8 == true
, it uses UTF-8 (against spec)Spec
From ISO spec page 20:
The text was updated successfully, but these errors were encountered: