groups

name language licence
Force Application Crash Objective-C Other
64-bit Number from a String Perl Other
FourCharCode to NSString Objective-C Other
Printing Binary Representation of String C Other
ROT13 Objective-C Other
NSIndexSet to String Objective-C Other
getBoundingClientRect from WebKit using JavaScriptCore Objective-C Other
NSImage Create QuickLook icon for URL Objective-C Other

< 1 2 3 4 >



language: Perl
licence: Other

64-bit Number from a String

options: view full snippetsend to code collector
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";'
	
(Continues...)