|
Post by alincon on Jun 22, 2020 20:46:18 GMT -5
I would like to save space in files that have lots of phone numbers, ssns, zip codes, etc. Converting to Hex saves only one byte. Is there some other simple conversion method available?
r.m.
|
|
|
Post by honkytonk on Jun 23, 2020 1:01:38 GMT -5
|
|
|
Post by BeeTrap on Jun 24, 2020 8:46:48 GMT -5
I have never used this code so I have no idea if it is what you are after, but there is code for "LZW compression" at Rosetta Code If it works, please post your thoughts.......thanks.
|
|
|
Post by alincon on Jun 26, 2020 13:52:56 GMT -5
Actually I am just looking to save phone numbers, ss nbrs and zip codes in less than 9 or 10 bytes. Isn't there a way to store two digits in one byte, each one using four bits?
r.m.
|
|
|
Post by Chris Iverson on Jun 26, 2020 14:28:34 GMT -5
You can try something like this, but because you won't be winding up with text anymore, but binary data, this may break your input routines.
phone = 8885551212
a$ = numBlob$(phone) print len(a$) print a$
print print blobNum(a$)
Function numBlob$(num) while num > 256
remainder = num mod 256 str$ = str$ + chr$(remainder) num = int(num / 256) wend str$ = str$ + chr$(num) numBlob$ = str$ End Function
Function blobNum(str$) for x = len(str$) to 1 step -1 blobNum = (256 * blobNum) + asc(mid$(str$, x, 1)) next x End Function
The code converts the number to a binary blob, basically the raw internal binary representation of the number. Five bytes will cover all US phone numbers.
If you have files that have a lot of text, including full addresses and names, etc, then you'd probably get better storage minimization results using some form of full file compression, as suggested above.
|
|