MUHUHAHAHAHA! Fingerprinting has been conquered! Take *that*, PulkoMandy! -- Travis D. Reed On Sun, Feb 7, 2010 at 3:46 PM, PHilip RUshik <prushik@xxxxxxxxx> wrote: > On Sun, Feb 7, 2010 at 4:40 PM, Travis D. Reed <tdreed@xxxxxxxxx> wrote: > >> Alright! Finally I tracked down the problem thanks to the cool double-s in >> David A.'s name. C++ understands the two chars that make up this one >> character as negative. PHP considers them positive...Clearly something to do >> with the size of char...now I just need figure out how to manipulate this >> and I'm in business! :) >> >> C++ // -61 -97 = SS >> PHP // 195 159 = SS >> -- >> Travis D. Reed >> >> >> >> On Sun, Feb 7, 2010 at 3:04 PM, Travis D. Reed <tdreed@xxxxxxxxx> wrote: >> >>> I love the idea of the StringBuilder. >>> >>> I'm all too familiar with the code you mentioned, Ryan. :) Yesterday, I >>> stripped said code out of the LocaleKit to make a little C++ app that >>> calculates (correctly) the code. It works for the moment (though calling it >>> in PHP sometimes breaks things because I've not properly escaped one single >>> string in the Mail App). I still would like to get a pure PHP solution. >>> >>> Still working. >>> >>> -- >>> Travis D. Reed >>> >>> >>> >>> On Sun, Feb 7, 2010 at 1:50 PM, Ryan Leavengood <leavengood@xxxxxxxxx>wrote: >>> >>>> On Sun, Feb 7, 2010 at 2:35 PM, Travis D. Reed <tdreed@xxxxxxxxx> >>>> wrote: >>>> > This is the problem. (Ironically, I used to fight against this with >>>> PHP, now >>>> > it does it by itself.) I'm trying to peal off just 8 bits at a time >>>> from the >>>> > string, but the way I'm doing it, it counts ellipsis as a >>>> char...*sigh* >>>> > Still working on it. >>>> >>>> By the way, I was looking at the problem of generating the catkeys >>>> signature and the algorithm is pretty simple. I was trying to code it >>>> up in Ruby but the main problem there is that the Haiku C++ code for >>>> calculating the fingerprint counts on 32-bit integer overflow >>>> arithmetic, whereas Ruby has the Bignum class which automatically >>>> handles big numeric calculations, and this makes it harder to >>>> reproduce what the C++ code does. The main point of all this though is >>>> that you should be able to reproduce this algorithm in PHP, assuming >>>> you can treat the UTF-8 strings just as a stream of bytes and do >>>> 32-bit unsigned calculations. >>>> >>>> If you want to look the fingerprint code is in this file (in >>>> CatKey::HashFun and BHashMapCatalog::ComputeFingerprint): >>>> >>>> >>>> http://dev.haiku-os.org/browser/haiku/trunk/src/kits/locale/HashMapCatalog.cpp >>>> >>>> -- >>>> Regards, >>>> Ryan >>>> >>>> >>> >> > In C++ a char is one byte, so 195 = 11000011 = -61. I always just use > unsigned chars to prevent that whenever I have to worry about that. > Hope my insight is helpful instead of annoying. > > -PHilip RUshik > >