QR barcode carriage return

放肆的年华 提交于 2020-01-02 07:09:17

问题


How do you encode a carriage return in a QR barcode (so if I scan it with my android, for instance it will come up)

A
B
C

I have tried A~d013B~d013C etc. but it always shows the escape characters (among other ways I have found, none of which seem to work)


回答1:


You simply encode it by putting the correct byte sequence into the QR code. Assuming you're using the default ISO-8859-1 encoding, that's just the single byte 0x0D.

I imagine you know this so perhaps you are really asking how to specify this character/byte to some particular encoder? I can tell you that http://zxing.appspot.com/generator/ will easily let you do this in its "Text" mode as it gives you textarea to type into, where you can simply type a carriage return.

It in turn just generates a URL to the chart server:

http://zxing.org/w/chart?cht=qr&chs=350x350&chld=L&choe=UTF-8&chl=a%0Ab%0Ac

Here it's actually inserted line feeds (is that what you mean?), but you could edit the URL above to insert %0D for a carriage return as you like.




回答2:


I know this is old, but it's still one of the top results in Google and I'd like to add for future searches the JavaScript encoding.

Inside JavaScript you can do this using \u000A to insert LF or \u000D to insert CR. For example:

const qrData = 'Line 1 ' +
    '\u000A Line 2' +
    '\u000A Line 3' +
    '\u000A Line 4';



回答3:


Change <:CR> to %0D and it will line break for you as you'd like.



来源:https://stackoverflow.com/questions/8422042/qr-barcode-carriage-return

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!