Re: little endian read

2016-11-17 Thread Stephen R. van den Berg
Tobias S. Josefowitz wrote: >On Thu, Nov 17, 2016 at 11:37 AM, Stephen R. van den Berg 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

Re: little endian read

2016-11-17 Thread Stephen R. van den Berg
Lance Dillon wrote: >But, I found something even easier.?? It's been a while since I've used it, >but I remembered ADT.Struct, and it has Drow() and Gnol() types, which are >Intel (little-endian) versions of Word() and Long() types.?? Those do exactly >what I need, so even easier. Indeed. Forg

Re: little endian read

2016-11-17 Thread Lance Dillon
But, I found something even easier.  It's been a while since I've used it, but I remembered ADT.Struct, and it has Drow() and Gnol() types, which are Intel (little-endian) versions of Word() and Long() types.  Those do exactly what I need, so even easier. Basically I'm writing a program to conve

Re: little endian read

2016-11-17 Thread Lance Dillon
Ah, there we go.  I tried to find sscanf, but it isn't on the Pike Reference Manual - namespace predef | | | 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 missin

Re: little endian read

2016-11-17 Thread Tobias S. Josefowitz
On Thu, Nov 17, 2016 at 11:37 AM, Stephen R. van den Berg 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 begi

Re: little endian read

2016-11-17 Thread Stephen R. van den Berg
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. >Trying to find an easy way to make it variable, like 2 or 4 byte