No, you don't use pack() to do it. It packs the number in a binary representation that is never portable. And it's not printable.
Just use sprintf() and it should be fine. You can cast it to arbitrary precision as needed (provided that is supported):
I can use printf() directly - just to show you that sprintf() returns a string representation that can be assigned to a scalar variable for later printing, storage or other processing.
hello.
i use follow sentences in include files in SCO unix is ok.
#pragma pack(1)
struct dddd {
int iD1;
char cCh1;
...
};
#pragma pack()
but in hp-9000 unix , not ok when compiling, cc not support
#pragma pack(1)
how to settle the question ?
... (1 Reply)
ok guys and gals at the moment i am perplexed (prolly cuz i been looking at it to long) but here it is.
OS: sol8
perlver: 5.8.0
shell: ksh
answer must be in perl!!
issue:
when i use pack() it packs the data at the front of the requested field space. normally it wouldnt be a problem if... (1 Reply)
I've recently installed ServicePack1 for Tecnology_Level 9 of AIX 5.2 .
The result of installation is "OK" but with oslevel -s i dont see the service pack installed ....
after many research i try (with many luck!!)
instfix -i|grep SP
and the result :
All filesets for 5200-08-01_SP... (1 Reply)
How do I pack (using tar zcvf ?) the current folder inluding all files and folders ??
I need to be sure to get all files and folders/subfolders...
Later I will unpack into a new folder on a new server..
Appreciate any help.. (3 Replies)
I have a file that contains user id and corresponding password.
Lets say password is "help". The below command will create a hex value for string "help".
perl -e 'print unpack "H*","help"'
So now password is in encoded format.
Then I decoded it in the script where am fetching the... (1 Reply)
I wondering if anybody tried already or know about the performance to process some Oracle staff from Perl.
I see it could be done by the DBI pachage (so, I guess, it is interface to the OCI, but who know how sufficiant it is..,) with all gemicks around (define, open, parce, bind,.. ), or it can... (8 Replies)
Hi ALL,
I am running weblogic portal(9.2.2) on solaris and i wanted to apply maintenance pack and upgrade it to 9.2.3. Without using
x-windows system how can i apply maintenance pack.? (0 Replies)
Hi I have a code like this:
sub WriteEbcdicHeader
{
my $Htimestamp=localtime();#i need to pack and unpack this
my $eheaderline = $Htimestamp;
#packing has to be done here
#unpacking has to be done after packing
print $EOUTFILE
return $eheaderline;
}
sub WriteEbcdicTrailer
{
... (5 Replies)
Discussion started by: rbathena
5 Replies
LEARN ABOUT PHP
crc32
CRC32(3) 1 CRC32(3)crc32 - Calculates the crc32 polynomial of a stringSYNOPSIS
int crc32 (string $str)
DESCRIPTION
Generates the cyclic redundancy checksum polynomial of 32-bit lengths of the $str. This is usually used to validate the integrity of data
being transmitted.
Warning
Because PHP's integer type is signed many crc32 checksums will result in negative integers on 32bit platforms. On 64bit installa-
tions all crc32(3) results will be positive integers though.
So you need to use the "%u" formatter of sprintf(3) or printf(3) to get the string representation of the unsigned crc32(3) checksum
in decimal format.
For a hexadecimal representation of the checksum you can either use the "%x" formatter of sprintf(3) or printf(3) or the dechex(3)
conversion functions, both of these also take care of converting the crc32(3) result to an unsigned integer.
Having 64bit installations also return negative integers for higher result values was considered but would break the hexadecimal
conversion as negatives would get an extra 0xFFFFFFFF######## offset then. As hexadecimal representation seems to be the most common
use case we decided to not break this even if it breaks direct decimal comparisons in about 50% of the cases when moving from 32 to
64bits.
In retrospect having the function return an integer maybe wasn't the best idea and returning a hex string representation right away
(as e.g. md5(3) does) might have been a better plan to begin with.
For a more portable solution you may also consider the generic hash(3). hash("crc32b", $str) will return the same string as
dechex(crc32($str)).
PARAMETERS
o $str
- The data.
RETURN VALUES
Returns the crc32 checksum of $str as an integer.
EXAMPLES
Example #1
Displaying a crc32 checksum
This example shows how to print a converted checksum with the printf(3) function:
<?php
$checksum = crc32("The quick brown fox jumped over the lazy dog.");
printf("%u
", $checksum);
?>
SEE ALSO hash(3), md5(3), sha1(3).
PHP Documentation Group CRC32(3)