Double accented capital letters, such as ÙÇ, ÙÉ, ÀÇ, and ÈÏ, are not well decoded in a qrcode. Is there a way to fix that ?

\usepackage{fontspec} % if this package is not present, the accented text outside the qrcode disappear

The following qrcodes work well: \\[20pt]
À \qrcode[]{À} ~~ 
É \qrcode[]{É} ~~
Ù \qrcode[]{Ù} ~~ 
Ç \qrcode[]{Ç} \\[20pt]
È \qrcode[]{È} ~~ 
Ï \qrcode[]{Ï} ~~
ÀÉ \qrcode[]{AÉ} ~~ 
Ù Ç \qrcode[]{Ù\ Ç} \\[20pt]
àçéùï \qrcode[]{àçéùï}\\[20pt]

The accented characters are not well decoded in the following qrcodes:\\[20pt]
ÙÇ \qrcode[]{ÙÇ} ~~ 
ÙÉ \qrcode[]{ÙÉ} ~~ 
ÀÇ \qrcode[]{ÀÇ} ~~ 
ÈÏ \qrcode[]{ÈÏ} \\[20pt] 
ÀÉÙÇ \qrcode[]{ÀÉÙÇ} ~~ 
àùéèçïÀÉÙÇÈÏ \qrcode[]{àùéèçïÀÉÙÇÈÏ} 


The following qrcodes work well when the Accented Capital Letters are separated by a space: \\[20pt]

Ù Ç \qrcode[]{Ù\ Ç} ~~ 
Ù É \qrcode[]{Ù\ É} ~~ 
À Ç \qrcode[]{À\ Ç} ~~ 
È Ï \qrcode[]{È\ Ï} \\[20pt] 
À É Ù Ç \qrcode[]{À\ É\ Ù\ Ç}\\[20pt]

The following qrcode translates (?) into asian characters when the Accented Capital Letters are separated by a space: \\[20pt]

àùéèçï À É Ù Ç È Ï \qrcode[]{àùéèçï\ À\ É\ Ù\ Ç\ È\ Ï} 


enter image description here

enter image description here

  • 2
    Which engine do you use? LuaLaTeX or XeTeX? As well, using anything but lower ASCII in a QR code sounds like a bad idea, similar to using it in your username or password. You can only expect troubles everywhere (not just in their generation, in their reading as well). – yo' Mar 2 '15 at 0:08
  • The engine is LuaLateX – SDrolet Mar 2 '15 at 0:14
  • According to wikipedia, it looks like QR code does not support unicode directly. So it depends on what are you encoding? A URL so À goes to %C3%80? A piece of text with specific decoder? Do you want to change to more efficient encoding like this? – Symbol 1 Mar 3 '15 at 3:15
  • I have updated my code to show that the accented capital letters are well decoded when alone or separated by a space: so, "À" is perfect alone, but not when side by side with Ç (with a few exceptions like ÀÉ). Why aren't they well decoded when they are close to each other ? Does an accented capital letter need more space to be well decoded ? – SDrolet Mar 4 '15 at 17:04
  • As mentioned by Symbol1 (see answer below), "ÀÉ" doesn't work well: in my example, "AÉ" is in the QRcode instead of "ÀÉ". – SDrolet Mar 6 '15 at 13:52

As I mentioned in comment, QR code does not support Unicode directly. And the implement of qrcode package uses the following lines to convert characters to number:

  % #1 = hex codes translated so far
  % #2 = next plaintext character to translate
  % #3 = remainder of plaintext
    % All done!
    % Another character to translate.

As you can see, \number`#2 is a macro that

  • sends A to 41
  • sends É to c9
  • sends Ù to d9
  • sends Ç to c7
  • and so on...

Does qrcode works well?

It almost does. Those characters are converted to corresponding numbers and hence lead to good QR images.

For instance, the raw data of ÙÇ is

40 2d 9c 70 ec 11 ec 11   ec


In case of Ù Ç, the raw data is

40 3d 92 0c 70 ec 11 ec   11


So, what's wrong?

Things masses up during decoding. Turns out that decoders recognizes d920c7= Ù Ç but not d9c7=ÙÇ. I cannot explain this. And the last case is even funnier:

41 2e 0f 9e 9e 8e 7e f2   0c 02 0c 92 0d 92 0c 72   0c 82 0c f0 ec 11 

The first recognizable character e0f9 is in Shift JIS, an encoding supported by QR code. Thus the decoder will change to Shift JIS and output 瓊鳧鉐 タ ノ ル ヌ ネ マ as result.

But why ÀÉ behaves well?

No it does not. The raw data is

40 24 1c 90 ec 11 ec 11   ec 

Which is but not ÀÉ.

How to solve it?

First of all if you are encoding French, characters like Œ, œ, and the very rare Ÿ may cause fail. You probably need to rewrite the macro mentioned above.

Otherwise if you are satisfies with ASCII, you need to force your decoder reads characters after 0xFF=127. Nothing to do with TeX here.

  • Very clear and informative answer. Thanks ! – SDrolet Mar 6 '15 at 13:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.