Ah, there we go.  I tried to find sscanf, but it isn't on the Pike Reference Manual - namespace predef



Module Tree Reference.  I had to go to the main doc page and search for sscanf.  printf also isn't listed.  Is it missing, or am I just missing it?  array_sscanf is present, and says it uses the same format specifiers as sscanf, but didn't have a link to sscanf.

That does exactly what I need, thanks.


On Thursday, November 17, 2016 6:20 AM, Tobias S. Josefowitz <t.josefowitz@gmail.com> wrote:


On Thu, Nov 17, 2016 at 11:37 AM, Stephen R. van den Berg <srb@cuci.nl> wrote:
> Lance Dillon wrote:
>>Stdio.File fp;fp=Stdio.File(filename,"r");string str=fp->read(2);int res=array_sscanf(reverse(str),"%2c")[0];
>
> Using %2c to read little endian probably only works on CPUs that are
> little endian to begin with.

To quote from sscanf() documentation:


"%c"

Reads one character and returns it as an integer ("0101" makes 48, or
'0', leaving "101" for later directives). Using the field width and
endianness modifiers, you can decode integers of any size and
endianness. For example "%-2c" decodes "0101" into 12592, leaving "01"
fot later directives. The sign modifiers can be used to modify the
signature of the data, making "%+1c" decode "รค" into -28.

"-"
Supplying a minus sign toggles the decoding to read the data encoded
in little-endian byte order, rather than the default network
(big-endian) byte order.