How can I keep text formatted using a QR code? - yaml

I would like to use a qr code to transmit yaml.
Is there anyway to keep the text formatted when a scanner reads the code?
Where can I read about implementing a custom format for a qr code?

Just include line breaks, tabs and spaces in the text payload, if that's what you mean. You can't force a reader to honor all that when displaying the payload. But you can include it all the same.

You will need to URL Encode the text before you encode it as a QR code.
Just as the space symbol is encoded as %20 linebreaks are commonly encoded as %0A
See http://en.wikipedia.org/wiki/Percent-encoding for details.
Generally speaking the JavaScript function escape() is good enough for this, although you may want to look at encodeURI() or encodeURIComponent() depending on your needs - see http://www.javascripter.net/faq/escape.htm for a good discussion on the differences.

Related

Zebra RW420 is printing the ZPL commands to get TID

I am trying to printing TID FROM ZPL COMMANDS
getting JJL179464
can anyone please tell me
what is this character
To partially answer your question:
Are you reading an ASCII encoded data? Because your result: "JJL179464" does not look like a valid RFID tag data, unless it is in ASCII. Data encoded in RFID tags are encoded in binary. Depending on reader settings, the data can be outputed in binary, hexadecimal or ASCII format. Judging by the first three symbols "JJL", your reader is set to output ASCII data, or there is an error in your code.
Try to answer us the following questions:
What are you trying to achieve?
Provide us your code. (whole, structured)
What device are you using to read the RFID tag?
Provide us the settings of your reading device. (unless they are a part of the code)
Do you know the data content of the RFID tag you are trying to read? That means, can you validate that the reading was successful?
Edit:
Thank you for your code:
^XA
^FN1^RFR,H,0,12,2^FS^FH_^HV1,256^FS
^XZ
It seems that there could be several issues in your code.
Firstly, your ^HV command is incomplete. It is missing 3 parameters. The first one (third parameter) sets the data prefix. Next one data termination. And the last one specifies when to return data. You should include all of them in the ^HV command.
There is already a good example how the ^HV command needs to be set:
^RFR,^FN1,^HV1 not sending output to computer
The second issue, at least I think that it is an issue but I don't have the means to verify it, is that you are using ^FH_ command. There are no hexadecimal values for encoding special characters in your code, so there is no point in using it. So I would try to omit it.
Also, I am not sure about the order of commands. The ^FN1 command should be after ^RFR and before ^FS commands.
Try this code:
^XA
^RFR,H,0,12,2^FN1^FS^HV1,256,HEADER,TERMINATION,L^FS
^XZ
That should give you output in format:
HEADERhexadecimaldataTERMINATION
It is a little bit hard to read, but if it will work, then you might proceed to format it nicely.
The words HEADER and TERMINATION serve as prefix and postfix of data from ^RFR command. So if this will work you can replace them with brackets or whatever suits your needs.
I am also concerned about 2 things:
The number of bytes to read - 12. Usually it is 8, but it varies depending on the type of RFID tag and the data format. I don't say that it is a mistake, just unsual to me.
The last parameter in ^HV1 command may be "F" instead of "L". The "F" is default value and it seems that in your case it was working with it. At least you got some output, so maybe it should be "F". But try it with "L" to get a response for each label. "F" means getting a response after the entire job is done.
I hope this will work. Currently we are in lockdown and I don't have the means to verify this on real devices. But theoreticaly it should help.
Please let me know the results.

Using sound to encrypt any file?

First Question: Say I have a random Base64 encoded string. Is it possible to read each character on the string and convert each character to a frequency/sound and then same the string as a sound?
Second Question: Is it possible to do the opposite? How would I take a sound that was created above and convert back to a base64 string?
If someone clicked no the audio encrypted file it would just be noise.
Yes, it's possible and actually being used, for example here: http://arstechnica.com/tech-policy/2015/11/beware-of-ads-that-use-inaudible-sound-to-link-your-phone-tv-tablet-and-pc/
A Perl script for this is beyond a single answer, but there are many Sound-related modules on CPAN: http://search.cpan.org/search?query=sound&mode=all You'll probably need some time for research, but it should be more or less easy to build.

Using Subscript and Superscript in Processing 2?

I'm trying to achieve something along the lines of:
Water = H^2O
Is this possible in Processing 2.2?
There are a couple options. If you only want a few simple super/subscripts, you might as well just use unicode:
String s = "H\u2082O";
text(s,10,20);
Where \u2082 is unicode for the ₂ character. If you want more advanced control, you could use this code from the processing forum, which can super/subscript whatever you want, rather than hardcoding the characters. The code is too big to copy here, but you should be able to include the SuperSubText class in your sketch and then use formatting strings like H<sub>2</sub>O in your code.

Testing for extended characters in watir-webdriver

I need to check for text with extended character set characters in my watir-webdriver scripts.
For example checking for a link has the follow text;
Weiß
I read the text from a CSV file, which when edited looks like the above text.
But when running the test in FireFox I get the following failure.
Wrong values on attribute table after add all save.
<"Wei\247"> expected but was
<"Wei\303\237>.
I tried saving it in the CSV as Wei\303\237 but the expected value then had double backslash characters.
How can I encode this in the CSV so I can check the text value safely cross platform and browser?
I had this problem, and I got around it by writing it in the spreadsheet as something like {S} and gsubbing it when I read the file into Ruby. If you gsub the text when you check the link too then basically you have your own encoding method for special characters. This is a long way around, so I'd be very interested in other answers.
The double backslash is probably because when your code reads from the CSV it escapes the backslashes in the file to preserve the text. Therefore you can't put the unicode in your CSV file. I don't really know a way around this. I hear that Ruby unicode support isn't that great, but is being worked on as of 1.9.x.

ruby string encoding

So, I'm trying to do some screen scraping off of a certain site using nokogiri, but the site owners failed to specify the proper encoding of the page in a <meta> tag. The upshot of this is that I'm trying to deal with strings that think they're utf-8, but really aren't.
(If you care, here are the files I was using to test this:
main file: http://dpaste.de/nif5/
ann.html: http://dpaste.de/YsLM/
ann2.html: http://dpaste.de/Lofi/
ann3.html: http://dpaste.de/R21j/
a-p.html: http://dpaste.de/O9dy/
output: http://dpaste.de/WdXc/
)
After doing a lot of searching around (this SO question was particularly useful), I found that calling encode('iso-8859-1', 'utf-8') on that test string "works", in that I get a proper © symbol. The issue now is that there are other characters in some other strings I want that really do not work at being converted to latin encoding (Shōta, for instance, turns into Sh�\x8Dta).
Now, I'm probably going to bother the appropriate webmasters and try and get them to fix their damn encodings, but in the meantime, I'd like to be able to use the bytes that I've got. I'm fairly certain that there is a way, but I just can't for the life of me figure out what it is.
Those pages appear to be correctly encoded as UTF-8. That's how my browser sees them, and when I viewsource them and tell the editor to decode them as UTF-8, they look fine. The only problem I see is that some copyright symbols seem to have been corrupted before (or as) they were added to the content. The o-macron and other non-ASCII letters come through just fine.
I don't know if you're aware of this, but the proper way to notify clients of a page's encoding is through a header. Pages may include that information in <meta> tags, but that's neither required nor expected; browsers typically ignore such tags if the header is present.
Since your pages are XHTML, they could also embed the encoding information in an XML processing instruction, but again, they're not required to. But it als means you could have Nokogiri treat them as XML instead of HTML, in which case I would expect it to use UTF-8 by default. But I'm not familiar with Nokogiri, so I can't be sure. And anyway, the header is still the final authority.
So, the issue is that ANN only specifies encoding via headers, and Nokogiri doesn't receive the headers from the open() function. So, Nokogiri guesses that the page is latin-encoded, and produces strings that we really can't reverse to get back the original characters from.
You can specify the encoding to Nokogiri as the 3rd parameter to Nokogiri::HTML(), which solves the issue I was initially trying to solve. So, I'll accept this answer, even though the more specific question I asked (how to get those non-latin characters out of a latin string) is unanswerable.

Resources