how can I convert an EAN-13 or Code-128 barcode generated from a weighing scale machine back to a user-defined object?
Class Product
{
string name = "Apples";
deciaml qty = "0.5";
double value = "5";
}
I already found libraries but all decodes barcode provided as an image. in my case, I have a barcode reader which will be reading the barcode label and input it as numbers something like (2032156478954).
what library or how can I decode those barcode numbers back to my object?
assume that I know from the user manual of the weighing scale which part is the product name, qty, and value
just like those label barcode we see in hypermarkets where you buy fruits and veggies in KG or Gram, it prints a barcode label, then the barcode label on POS is converted back to product object.
I am totally new when it comes to handling barcodes in .NET, any help, suggestion, or advice will be appreciated.
Example of Weighing Scale Barcode
Currently, I have solved it by implementing my own solution.
assume the barcode is 2 53647 2 5262 9 (EAN-13)
from the left-hand side, 2 tells the POS this is a barcode from the weighing scale machine, 53647 will be the ID of the item in the database.
2 tells the POS next 5 digits are the price of the item (52.62)
the last digit always discarded
the downside of this method is you will have to change either the settings of your weighing machine for every new setup you make to match your function. or you will change your code to match how the machine is printing barcodes since there is no one international standard.
I was hoping for a library that would have built-in functionality to recognize and decode those barcodes based on leading numbers and other check numbers. I might start building my own after looking at the most used formats.
If you already have a the string, as others pointed out you theoretically just nid to split the barcode and fill you class.
If you have a look here:
https://www.codeproject.com/Articles/10162/Creating-EAN-13-Barcodes-with-C
It shows you what the single numbers mean.
However:
If you want to figure out the values behind the numbers, then thats a little bit tricky. I expect the manufacturer code, if internationally standardized is something that will change over time. Because someone registers a new manufacturer and therefore gets a new code.
This would imply your programm needs access to the internet resp. to this database where they are registered.
Before putting to much effort in it, ask you self:
Do I really need to have this informations that well prepared, for the project am I'm doing or would it be completely fine if you just split the strings and have as manufacturer for example "50603" without knowing whats behind.
I just give you this sample for the EAN code, but I would say you can apply this to other codes as well.
Related
I am using "PosPrinter" .NET class to print receipts to POS Printer. Everything seems to be working fine except the line breaks. When I pass in a long string it does automatically breaks the long line into more than 1 line but it actually breaks WITHIN the word.
So, I need a way to break the word instead of breaking within the word. I appreciate your help. T
Code
m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|N华夷风起 : 华夷风起:槟城文史研习营 = When the wind of the Sinophone blows: Penang seminar 2019.\n");
There is no such specification in POS for.NET(UnifiedPOS).
If that is the case, it may be a special feature of particular printer hardware or service object.
Please ask the printer vendor about the availability of such a function and ON/OFF.
If more information about the printer vendor and model is added, someone may be able to answer.
However, since there is probably no such function, you will need to read the value of the RecLineChars property and edit the content to be printed in advance by the application itself.
I'm using C# language for a project. I need to provide user with large (9+ digit) number, which they will have to reenter into another system (for later data correlation). Having a user enter a number that large (by hand) with no errors will be almost impossible.
I have been trying to come up with a solution to shorten that number using base64, but all the code I have found will create a string combination of character and digits. Is there a simple math algorithm I can use to make a large number smaller? The result should be numeric not alpha numeric.
You address the problem in a wrong way, instead of changing the number size just build a convenient way for the user to copy past the number , a simple key event wich will copy the number to the buffer, then the user will not have to write the number down.
Reducing a number using only numbers will never work.
What you really need is some form of error checking.
One that works very good is the Verhoeff Algorithm that will detect almost every typo. There are many examples to find online.
like:
https://www.codeproject.com/articles/15939/verhoeff-check-digit-in-c
You can use a Hash algorithm to hash your large number, but you need to deal with hash collision.
One of those very easy to implement is checksum sum16:
https://en.wikipedia.org/wiki/List_of_hash_functions
See sum16 you can only have 0-65536. Think about sum18 ?
I've Google'd and read quite a bit on QR codes and the maximum data that can be used based on the various settings, all of it being in tabular format. I can't seem to find anything giving a formula or a proper explanation of how these values are calculated.
What I would like to do is this:
Present the user with a form, allowing them to choose Format, EC & Version.
Then they can type in some data and generate a QR code.
Done deal. That part is easy.
The addition I would like to include is a "remaining character count" so that they (the user) can see how much more data they can type in, as well as what effect the properties have on the storage capacity of the QR code.
Does anyone know where I can find the formula(s)? Or do I need to purchase ISO 18004:2006?
A formula to calculate the amount of data you could put in a QRcode would be quite complex to make, not mentioning it would need some approximations for the calculation to be possible. The formula would have to calculate the amount of modules dedicated to the data in your QRCode based on its version, and then calculate how many codewords (which are sets of 8 modules) will be used for the error correction.
To calculate the amount of modules that will be used for the data, you need to know how many modules will be used for the function patterns. While this is not a problem for the three finder patterns, the timing or the version/format information, there will be a problem with the alignment patterns as their number is dependent on the QRCode's version, meaning you anyway would have to use a table at that point.
For the second part, I have to say I don't know how to calculate the number of error correcting codewords based on the correction capacity. For some reason, there are more error correcting codewords used that there should to match the error correction capacity, as for example a 6-H QRCode can correct up to 32.6% of the data, instead of the 30% set by the H correction level.
In any case, as you can see a formula would be quite complex to implement. Using a table like already suggested is probably the best thing you could do.
I wrote the original AIM specification for QR Code back in the '90s for Denso Corporation, and was also project editor for both editions of the ISO/IEC 18004 standard. It was felt to be much easier for people producing code printing software to use a look-up table rather than calculate capacities from a formula - no easy job as there are several independent variables that have to be taken into account iteratively when parsing the text to be encoded to minimise its length in bits, in order to achieve the smallest symbol. The most crucial factor is the mix of characters in the data, the sequence and lengths of sub-strings of numeric, alphanumeric, Kanji data, with the overhead needed to signal each change of character set, then the required level of error correction. I did produce a guidance section for this which is contained in the ISO standard.
The storage is calculated by the QR mode and the version/type that you are using. More specifically the calculation is based on how 'compressible' the characters are and what algorithm that the qr generator is allowed to use on the content present.
More information can be found http://en.wikipedia.org/wiki/QR_code#Storage
I'm developing an application for taking orders in C# and DevExpress, and I need a function that generates a unique order number. The order number must contain letters and digits and has a length of 20 ..
I've seen things like Guid.NewGuid() but I don't want it to be totally random, nor to be just an auto increment number ..
Can anyone help? even if it's a script in a different language, I need ideas desperately :)
You can create type of your own .
lets say yyyyMMddWWW-YYY-XXXXXXX where WWW is the store number, YYY the cashier id XXXXXXX is a hexadecimal number ( -> maybe an actual autoincrement number that you turn it into hex ) . This is just an idea . Im afraid you have to decide by the elements of your system how it will be .
edited : also if you can apply a check digit algorithm on it will also help in avoiding mistakes
Two different methods:
Create MD5 or SHA1 hash of current time
Hash of increment number
One thought comes to mind.
Take the DateTime.Now.Ticks convert it to hexadecimal string.
Voila, String.Format("{0:X}", value);
If not long enough , you said you need 20 digits, you can always pad with zeros.
Get the mother board ID
Get the hdd ID
Merge it by any way
Add your secret code
Apply MD5
Apply Base54
Result: the serial code which is linked to the currect client PC :)
My two cents.
If you need ideas then take a look at the Luhn and Luhn mod N algorithms.
While these algorithms are not unique code generators, they may give you some ideas on how to generate codes that can be validated (such that you could validate the code for correctness before sending it off to the database).
Like Oded suggested, Guid is not random (well, not if you have a network card). It's based on time and location coordinates. See Raymond Chens blog post for a detailed explanation.
You are best off using an auto incremented int for order ids. I don't understand why you wouldn't want to use it or failing that a Guid?
I can't think of any way other then an auto id to maintain uniqueness and represent the order of your different orders in your system.
I have an old Paradox database (I can convert it to Access 2007) which contains more then 200,000 records. This database has two columns: the first one is named "Word" and the second one is named "Mean". It is a dictionary database and my client wants to convert this old database to ASP.NET and SQL.
However, we don't know what key or method is used to encrypt or encode the "Mean" column which is in the Unicode format. The software itself has been written in Delphi 7 and we don't have the source code. My client only knows the credentials for logging in to database. The problem is decoding the Mean column.
What I do have is the compiled windows application and the Paradox database. This software can decode the "Mean" column for each "Word" so the method and/or key is in its own compiled code(.exe) or one of the files in its directory.
For example, we know that in the following row the "Zymurgy"
exactly means "مبحث عمل تخمیر در شیمی علمی, تخمیر شناسی" since the application translates it like that. Here is what the record looks like when I open the database in Access:
Word Mean
Zymurgy 5OBnGguKPdDAd7L2lnvd9Lnf1mdd2zDBQRxngsCuirK5h91sVmy0kpRcue/+ql9ORmP99Mn/QZ4=
Therefore we're trying to discover how the value in the Mean column is converted to "مبحث عمل تخمیر در شیمی علمی, تخمیر شناسی". I think the "Mean" column value in above row is encoded in Base64 string format, but decoding the Base64 string does not yet result in the expected text.
The extensions for files in the win app directory are dll, CCC, DAT, exe (other than the main app file), SYS, FAM, MB, PX, TV, VAL.
Any kind of help is appreciated.
here is two more example and remember double quotes at start and end are not part of the strings:
word: "abdominal"
coded value: "vwtj0bmj7jdF9SS8sbrIalBoKMDvTbpraFgG4gP/G9GLx5iU/E98rQ=="
translation in Farsi: "شکمی, بطنی, وریدهای شکمی, ماهیان بطنی"
word: "cart"
coded value: "KHoCkDsIndb6OKjxVxsh+Ti+iA/ZqP9sz28e4/cQzMyLI+ToPbiLOaECWQ8XKXTz"
translation in Farsi: "ارابه, گاری, دوچرخه, چرخ, با گاری بردن"
here is the result in different encodings:
1- in unicode the result is: "ᩧ訋퀽矀箖�柖�섰᱁艧껀늊螹泝汖銴岔也捆鹁"
2- in utf32 the result is: "��������������"
3- in utf7 the result is: "äàg\v=ÐÀw²ö{Ýô¹ßÖg]Û0ÁAgÀ®²¹ÝlVl´\\¹ïþª_NFcýôÉÿA"
4- in utf8 the result is: "��g\v�=��w���{����g]�0�Ag��������lVl���\\����_NFc����A�"
5- in 1256 the result is: "نàg\vٹ=ذہw²ِ–{فô¹كضg]غ0ءAg‚ہ®ٹ²¹‡فlVl´’”\\¹ïھ_NFcôةےA"
yet i discovered that the paradox database system is very complex when it comes to key management and most of the time the keys are "compound keys" and that's why it's problematic and that's why it's abandoned!
UPDATE: i'm trying to do the automation by using AutoIt v3 because the decryption process as i understand can't be done in one or two days. now i have another problem which is related to text/font. when i copy the translated text to notepad it will change to some unrecognizable text unless i change the font of notepad to the font of the translation software. if i type something in the notepad in Farsi it will show it correctly regardless of what font i've been chosen. more interesting is when i copy the text to any other program like MS Office Word it'll be shown correctly no matter what font i choose.
so how can i get around this ?
In this situation, I would think about writing a script/program to simply pull all the data out through the existing program.
You could write an application to send keypresses to the app which would select and copy each value in turn.
It would take a while to run, but you could just leave it overnight (how big is your database?) and it only has to run once.
Not sure how easy this would be, since I haven't seen this app of course - might this work?
Take a debugger like ollydbg/softice. Find the place where the mean is decoded/encoded and then step through the instructions one by one, check all registers to find out what is done. I have done so numerous times. That should help you getting started, since you have the application which is able to decode this stuff. You also have a reference word. That's all you need.
Also take into consideration: Unicode can be Little or Big Endian. So you might try swapping the bytes. UTF-8 can be a pain, since some words are stored as one byte and some as two bytes.
You can also try to take words which are almost identical in Farsi and try to compare the outputs. That could lead to a reconstruction of a custom code page, if there is one.