[haiku] Re: Proposals for the LocaleKit

  • From: "Travis D. Reed" <tdreed@xxxxxxxxx>
  • To: haiku@xxxxxxxxxxxxx
  • Date: Sun, 7 Feb 2010 15:47:54 -0600

Oh my! After playing with a calculator, this seems to be the mysterious
phenomenon of endianness I've been reading about. Bleh! You less-than-casual
programmers and weird numbers! I'm going to have to make a very PHPy
solution unless someone can explain how to shift bits around.
--
Travis D. Reed


On Sun, Feb 7, 2010 at 3: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
>>>
>>>
>>
>

Other related posts: