tags:

views:

298

answers:

2

How do you calculate the length of the string that would be returned by Array::pack? Is there something like Python's calcsize?

A: 

By making an interpreter complying to the specifications found in Array::pack.

Or, reusing the existing implementation to count the number of characters instead of appending them to a string.

Mikael Jansson
+1  A: 

array.pack("").count I would say. Not really the fastest method, but it works.

ChaosR