
Base32 conversion anybody ??
Hi all<BR> I have got a string of binary integers which needs to be looked up to a table and its corresponding value from the other column should be shown as output.<BR> I have this table which gives me the mapping of binary integers corresponding to its character value..<BR>If I have got a string like this "00111010001001110000111110010011000"<BR>this has to be looked up in to the table which is like<BR><BR>bits char<BR>00000 a<BR>00001 b<BR>00010 c <BR>00011 d<BR>00100 e<BR>00101 f<BR>00110 g<BR>00111 h<BR>01000 i<BR>01001 j<BR>01010 k<BR>01011 l<BR>01100 m<BR>01101 n<BR>01110 o<BR>01111 p<BR>10000 q<BR>10001 r <BR>10010 s<BR>10011 t<BR>10100 u<BR>10101 v<BR>10110 w<BR>10111 x<BR>11000 y<BR>11001 z<BR>11010 2<BR>11011 3<BR>11100 4<BR>11101 5<BR>11110 6<BR>11111 7<BR><BR>So if my input will be "00111010001001110000111110010011000" my out put should be "hitq7ey"<BR>what would be the easiest way to do this??? This is actually base 32 conversion

ANYONE ELSE ??
There must be some way for direct conversion ??<BR>maybe i'm notof much help<BR>

Run it in a loop
Looks like each characater has 5 numbers in its code... So make a loop that tears your string apart...<BR><BR>chrstr = "00111010001001110000111110010011000"<BR>do while len(chrstr) > 0<BR> teststr = left(chrstr,5)<BR> chrstr = right(chrstr,len(chrstr)5)<BR> SQL = "select field from table where keyfield='" & teststr & "'"<BR> objconn.open(StrConnect)<BR> set objrec = objconn.execute(SQL)<BR> if objrec(objrec.fields(0).name) <> "" then<BR> outstr = outstr & objrec(objrec.fields(0).name)<BR> end if<BR> objconn.close<BR> set objrec = nothing<BR>loop<BR>response.write(outstr)<BR><BR>W hat this does is it will look at the left 5 characaters of your string, compare then with your table, and then add its value to an output string. After reading the left 5, the loop will remove the left 5 from the string so that it can process the next 5.<BR><BR> Whol

for u wholsea
but I dont want to put that table into the database,can it be stored in some sort of an array or something.????

Yeah...
You can do the test however, you mentioned that you had it in a table, I *assumed* that the stuff was in a table... You can do a large ifthen structure, or a select statement, or anything, the concept is the same, I showed you how to pull the string apart, you can figure out what you want to test those chars against ;)<BR><BR>You may need to run your new string through another loop to look through an array for a corrisponding characater. Again, its up to you to figure out how you want to search for those characaters. It seems to me that they are stable settings for those characaters, a Select statement could probably be a pretty good solution to it...<BR><BR> Whol

Base *any* conversion?
Well, your numbering system is nonconventional. The normal way to display base32 is as 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,...<BR><BR>That is, 00000 binary becomes 0, same as it does for hex, octal, decimal, or binary.<BR><BR>But that's really a minor point, excepting that it means you can't use the standard code without changing it.<BR><BR>Anyway...<BR><BR>The "normal" way to do this would be to convert the input number, in any base, to computerinternal format and then convert it back out to your choice of output base. You can write the routines so that they can accept any base in and any base out, so you could convert base 13 to base 5, etc.<BR><BR>Are you *sure* you need this really weird base32 encoding, where zero is represented as "a"???<BR><BR>Really?<BR><BR>
Posting Permissions
 You may not post new threads
 You may not post replies
 You may not post attachments
 You may not edit your posts

Forum Rules

