9

I've tried to use the pst-barcode to generate QR codes, and ran into an issue with foreign characters.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pst-barcode}

\begin{document}
\begin{pspicture}(1in,1in)
  \psbarcode{ÆØÅæøå}{width=1.0 height=1.0}{qrcode}
\end{pspicture}
ÆØÅæøå
\end{document}

Incorrect (and complex) QR code
Incorrect (and complex) QR code

This does not give the expected (or wanted) result. Removing the \usepackage[utf8]{inputenc} solves the pst-barcode problem:

\documentclass{article}
\usepackage{pst-barcode}

\begin{document}
\begin{pspicture}(1in,1in)
  \psbarcode{ÆØÅæøå}{width=1.0 height=1.0}{qrcode}
\end{pspicture}
ÆØÅæøå
\end{document}

Correct QR code, but wrong encoding for text in LaTeX
Correct QR code, but wrong encoding for text in LaTeX

However, this breaks the input encoding of LaTeX... I presume that pst-barcode does not support UTF8.

What would be the best way to get both UTF-8 encoded LaTeX and correct QR codes for foreign characters?

2
  • Welcome to TeX.sx! You don't have to sign with your name since it automatically appears in the lower right corner of your post. You can include the images but remove the ! before them, then one with enough reputation can append it for them to appear inline.
    – N.N.
    Commented Jan 27, 2012 at 14:53
  • Thanks @N.N., understood - I now added the QR Code images. Commented Jan 28, 2012 at 12:48

1 Answer 1

5

inputenc redefines the foreign characters to actually be commands that generate the correct glyphs, but this does not work within \psbarcode. You must give the parse option, and then specify the characters by their three-digit ASCII code:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pst-barcode}
\begin{document}
\begin{pspicture}(1in,1in)
  \psbarcode{^198^216^197^230^248^229}{width=1.0 height=1.0 parse}{qrcode}
\end{pspicture}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .