There is a simple algorithm here:
http://en.wikipedia.org/wiki/Base64
My PHP is a bit too rusty to comment on the correctness of your code.
Basically Base64 works, by encoding each 6 bits into a character.
That means it produces 4 bytes per 3 input bytes, and always pads up
with =, to produce a string of a length divisible by 4.
I _think_ the strings ID columns are encoded as an UTF-8 byte array into
Base64.
Regards, Kenneth, GEOGRAF A/S
nclayton skrev:
I have created this function in php which gives me the correct value for
33181 ("nYEAAA==") but I would like for another pair of eyes (or 20) to see
if this is solid and if it can be simplified.
function MgBase64_encode($value){
$key="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
$dhv = dechex($value);
$grp = (strlen($dhv) / 2);
$arr = array();
for($i=0;$i<$grp;$i++){
$arr[$i] = substr($dhv,($i * 2),2);
}
$arr = array_reverse($arr);
$bvl = decbin(hexdec(join("",$arr)));
$chk = (strlen($bvl) % 6);
if($chk > 0){ $bvl = str_pad($bvl,(strlen($bvl) + (6 - $chk)),'0'); }
$grp = (strlen($bvl) / 6);
$arr = array();
for($i=0;$i<$grp;$i++){
$arr[$i] = substr($key,bindec(substr($bvl,($i * 6),6)),1);
}
return str_pad(join("",$arr),6,'A') . "==";
}
Nick
nclayton wrote:
Thank you for the reply and the link. I'd actually read that post, but it
gave me a bit of a headache trying to reverse the process...I'm rather new
to this mode of thinking (i avoided it as long as i could).
As far as the parcel number value is concerned, it needs to be a string
because they are different for each county that we deal with and are
typically 14-22 alphanumeric characters in length, such as
'1-023B-001.000'
Nick
JasonBirch wrote:
More details on this here:
http://tinyurl.com/2rrq3e
I'm definitely a bit rusty on this stuff, but in your initial problem
are you sure you want to be using a string value for the parcel id?
Jason
-----Original Message-----
From: nclayton
Subject: Re: [mapguide-users] Issues selecting a feature with custom
coding
Here are the results of both the mgos base64 value and the php
base64_encode
value:
Actual FeatId: 33181
MGOS Value: nYEAAA==
base64_encode Value: MzMxODE=
I found code for writing a base64 function in javascript, and it gives
the same result as the php function.
_______________________________________________
mapguide-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapguide-users
_______________________________________________
mapguide-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapguide-users