apologies if someone's done it before.
string=<passport email all in lowercase>
x=0;
c=<first character in string (unicode, so 2 bytes)>
while (c!=0){
x=x*101;
x=x+c;
c=<next character in string (unicode, so 2 bytes)>
}
return x;seems to use 2 bytes hardcoded, god knows what it does with unicode of 4 bytes (or even 8 these days? dunno.)
hope this helps people, gimme a shout in the about box or so if you use it in yr progs if you feel like it.
peace,
Will
edit: erm, big point i forgot to mention... use a 32-bit integer and let it wrap around.
edit 2: and unsigned, obviously.
[noroom says:]
we appreciate the use of code tags. next time add them yourself
This post has been edited by noroom: 13 September 2003 - 04:23 PM

Sign In
Register
Help

MultiQuote