groups

Link to this snippet:


Download to Code Collector

language: Perl
licence: Other

64-bit Number from a String

options: send to code collectorview all myztikjenz's snippets
Useful for int64_t input parameters, like what CGEventSourceSetUserData needs

The string in the foreach() loop needs to have a length of 8
Probably doesn't work if your string contains wide characters

perl -MMath::BigInt -e '$x=Math::BigInt->bzero(); foreach(split(//,"Hi_There")){printf("$_\t%d\n",ord($_)); $x <<= 8;$x+=ord($_);} print "$x\n";'