# Trying to use parentheses in a “psbarcode” adds a new line after the first right parenthesis + charset encoding error

I'm trying to use the pst-barcode package to create a vcard contained in a qrcode, and I was surprised to see that a vcard that was working with another programming language to generate my qrcode was not working with this package.

After investigation, it turns out that the problem was caused by psbarcode: after the first (and only the first!) use of left and right parentheses, a newline is created (instead of the first space after the right parenthesis).

(If it could help: I also found out that using a left parenthesis without the right one after just returned a blank qrcode)

Here is my current code:

\begin{pspicture}(25mm,25mm)
\begingroup
% The following def are used to solve a previous problem as
% there were "penalty @M" added for this characters
\def:{\string:}%
\def;{\string;}%
\psbarcode{%
MECARD:N:Doe,John;TEL:+1 (234) 567-8910;EMAIL:john@doe.com;;%
}{eclevel=L width=1.161 height=1.161}{qrcode}
\endgroup
\end{pspicture}


I know that we need, in general, to define a number without space and other characters in a vcard, but here I need it that way, and I think that it could be useful for other situations when we need to have parentheses in a vcard.

An other piece of information that could be useful: my current version of pst-barcode has this filedate : \def\filedate{2011/03/10}

Note: Using ^040 and ^041 instead of ( and ) and the parse option also solves the problem.

The new problem encountered after this correction is linked to the charset. Here is the second barcode I have :

        \psbarcode{%
BEGIN:VCARD^^J%
N:Doé;John^^J%
TEL;WORK:+1 ^040234^041 567-8910^^J%
EMAIL:john@doe.com^^J%
END:VCARD%
}{eclevel=L width=1.161 height=1.161 parse}{qrcode}


It seems that the returned element is not readable by all barcode readers, but if I remove the accent, it works well. The reader was tested with others utf-8 encoded barcodes, and the returned value was correct.

I tried to use an UTF-8 BOM (^239^187^191) but it was not working.

-

there are three possible ways to pass the data into the macro:

\documentclass{minimal}
\usepackage{pst-barcode}
\begin{document}

\begin{pspicture}(1.2in,1.2in)
\psbarcode{MECARD:N:Doe,John;TEL:+1 (234) 567-8910;EMAIL:john@doe.com;;}%
{eclevel=L width=1.161 height=1.161}{qrcode}
\end{pspicture}
%
\begin{pspicture}(1.2in,1.2in)
\psbarcode{MECARD\string:N\string:Doe,John\string;TEL:+1 (234) 567-8910\string;EMAIL\string:john@doe.com\string;\string;}%
{eclevel=L width=1.161 height=1.161}{qrcode}
\end{pspicture}
%
\begin{pspicture}(1.2in,1.2in)%% using ASCII decimal values, eg ^058->:
\psbarcode{MECARD^058N^058Doe,John^059TEL:+1 (234) 567-8910^059EMAIL^058john@doe.com^059^059}%
{eclevel=L width=1.161 height=1.161 parse}{qrcode}% option parse needed
\end{pspicture}
\end{document}


The data must be in one line! A % cannot be used as a TeX command character!

With this example:

\documentclass{standalone}
\usepackage[T1]{fontenc}
\usepackage{pst-barcode}
\pagestyle{empty}
\begin{document}

\begin{pspicture}(1.2in,1.2in)
\psbarcode{BEGIN:VCARD
N:Do^233;John^010
TEL;WORK:+1 ^040234^041 567-8910^010
EMAIL:john@doe.com^010
END:VCARD}
{eclevel=L width=1.161 height=1.161 parse}{qrcode}
\end{pspicture}
\end{document}


which i converted to a png image and uploaded it to http://zxing.org/w/decode I get:

BEGIN:VCARD N:Doé;John
TEL;WORK:+1 (234) 567-8910
EMAIL:john@doe.com
END:VCARD

-
In fact the multiline is not a problem at all (for instance, using a vcard - multiline format - is working well, except for parenthesis). The only problem is due to parenthesis. But it's funny because your code is not working for me (same problem that I had) but seems ok for you... (EDIT: perhaps linked to the fact that I'm using pdflatex with auto-pst-pdf package?) However, using the "parse" argument with ^040 and ^041 for the parenthesis, it seems to work ! (I have now an encoding problem, as I'm using some accents and I don't know why, but psbarcode don't want to compute them correctly) – XaF Mar 31 '12 at 7:28
sigh ... If you have problems with an accent, then show it in your question ... – Herbert Mar 31 '12 at 7:33
The "charset problem" is now described in the question ! (Thanks for your help about the first part, Herbert !) – XaF Mar 31 '12 at 7:49
a newline is ^013^010 (CRLF) and é is ^233. See de.wikipedia.org/wiki/ISO_8859. And, as I already wrote, write the data in ONE line – Herbert Mar 31 '12 at 7:57
For the newline, it does not seems to change anything. And about the ^233 : with N:Doe;John it's working, but without accent; with N:Doé;John and N:Do^233;John it's not working. :( (just to precise: I'm using the \usepackage[utf8]{inputenc} command) -- Exactly the same QRCode is output with the data in one line. – XaF Mar 31 '12 at 8:02