QR barcode carriage return

怎甘沉沦 提交于 2019-12-06 04:09:56

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.

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';
ben

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

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