Provided by: manpages-zh_1.5.2-1_all bug

NAME

       binary - ()

 SYNOPSIS
       binary format formatString ?arg arg ...?
       binary scan string formatString ?varName varName ...?
_________________________________________________________________

 DESCRIPTION
         binary format Tcl  16  2284 binary scan:  Tcl

 BINARY FORMAT
       binary format  formatString ()

       formatString (specifier) count(consume)count (item)count  *

       -(type-count) 0 ():

       a     count  arg  count  arg  count  *,  arg  count
                   binary format a7a*a alpha bravo charlie
             alpha\000\000bravoc

       A     a
                   binary format A6A*A alpha bravo charlie
             alpha bravoc.

       b     count ()Arg  1  0 (emit) arg  count  arg  count  *,  arg  count
                   binary format b5b* 11100 111000011010
             \x07\x87\x05

       B    () b
                   binary format B5B* 11100 111000011010
             \xe0\xe1\xa0

       h      count  ()Arg   0123456789abcdefABCDEF()(emit)  arg   count   arg
            count  * arg  count
                   binary format h3h* AB def
             \xba\x00\xed\x0f

       H    () h
                   binary format H3H* ab DEF
             \xab\x00\xde\xf0

       c    8 count arg  arg (low-order) 8  count  * count   count
                   binary format c3cc* {3 -3 128 1} 260 {2 5}
             \x03\xfd\x80\x04\x02\x05
                   binary format c {2 5}

       s    (little-endian)16 c16(significant)
                   binary format s3 {3 -3 258 1}
             \x03\x00\xfd\xff\x02\x01

       S    (big-endian)16 s
                   binary format S3 {3 -3 258 1}
             \x00\x03\xff\xfd\x01\x02

       i
             (little-endian)32 c32
                   binary format i3 {3 -3 65536 1}
             \x03\x00\x00\x00\xfd\xff\xff\xff\x00\x00\x01\x00

       I    (big-endian)32 i
                   binary format I3 {3 -3 65536 1}
             \x00\x00\x00\x03\xff\xff\xff\xfd\x00\x01\x00\x00

       f     c FLT_MAX  Tcl  Intel Pentium  Windows
                   binary format f2 {1.6 3.4}
             \xcd\xcc\xcc\x3f\x9a\x99\x59\x40

       d     f Intel Pentium  Windows
                   binary format d1 {1.6}
             \x9a\x99\x99\x99\x99\x99\xf9\x3f

       x    Stores count null bytes in the output string.   If  count  is  not
            specified,  stores  one  null  byte.   If count is *, generates an
            error.  This type does not consume an argument.  For example,
                   binary format a3xa3x2a3 abc def ghi
             abc\000def\000\000ghi

       X     count  count  *  0count
                   binary format a3X*a3X2a3 abc def ghi
             dghi.

       @     count  0  count (unitialized ?) count  * count
                   binary format a5@2a1@*a3@10a1 abcde f ghi j
             abfdeghi\000\000j.

 BINARY SCAN
       binary scan String  formatString  varName  string

        binary format formatString (specifier) count(consume)count (item)count
       *(untouch) binary scan

         (important)   c, s  S(64 i  II) (long) ()(1)(char  0x80 short  0x8000
       int  0x80000000):
              set signShort [binary format s1 0x8000]
              binary scan $signShort s1 val; # val == 0xFFFF8000
       (mask)  short :
              set val [expr {$val & 0xFFFF}]; # val == 0x8000

       -(type-count) 0 ():

       a     count  count  * string  count
                   binary scan abcde\000fghi a6a10 var1 var2
             1  abcde\000  var1  var2

       A    (strip)(blank)(null) a
                   binary scan "abc efghi  \000" A* var1
             1  abc efghi  var1

       b     count 10() count  *  count
                   binary scan \x07\x87\x05 b5b* var1 var2
             2  11100  var1  1110000110100000  var2.

       B    () b
                   binary scan \x70\x87\x05 B5B* var1 var2
             2  01110  var1  1000011100000101  var2.

       h     count  0123456789abcdefABCDEF () count  *,  count
                   binary scan \x07\x86\x05 h3h* var1 var2
             2  706  var1  50 n var2.

       H     h
                   binary scan \x07\x86\x05 H3H* var1 var2
             2  078 var1  05  var2.

       c     count 8 count  * count8
                   binary scan \x07\x86\x05 c2c* var1 var2
            2  7 -122  var1  5  var2.  8(quantity):
                   expr ( $num + 0x100 ) % 0x100

       s     count 16  count  * count16
                   binary scan \x05\x00\x07\x00\xf0\xff s2s* var1 var2
             2  5 7  var1  -16  var2.  16(quantity):
                   expr ( $num + 0x10000 ) % 0x10000

       S     count 16 s
                   binary scan \x00\x05\x00\x07\xff\xf0 S2S* var1 var2
             2  5 7  var1  -16  var2.

       i     count 32  count  * count32
                   binary scan \x05\x00\x00\x00\x07\x00\x00\x00\xf0\xff\xff\xff i2i* var1 var2
             2  5 7  var1  -16  var2 Tcl

       I     count 32 i
                   binary \x00\x00\x00\x05\x00\x00\x00\x07\xff\xff\xff\xf0 I2I* var1 var2
             2   5 7  var1  -16  var2

       f     count   count  * count  Intel Pentium  Windows
                   binary scan \x3f\xcc\xcc\xcd f var1
             1 1.6000000238418579  var1

       d     count  f Intel Pentium  Windows
                   binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f d var1
             1  1.6000000000000001  var11

       x     string  count  count  *  string count
                   binary scan \x01\x02\x03\x04 x2H* var1
             1 0304  var1

       X     string  count  count  *  0 string count
                   binary scan \x01\x02\x03\x04 c2XH* var1 var2
             2 1 2  var1  020304  var2

       @     countt  0  string  count  string  count
                   binary scan \x01\x02\x03\x04 c2@1H* var1 var2
             2  1 2  var1  020304  var2

 PLATFORM ISSUES
         tcl_platform   byteOrder

 SEE ALSO
       format(n), scan(n), tclvars(n)

 KEYWORDS
       binary, format, scan

[]


[]

       2001/06/21

 Linux  man :
       http://cmpp.linuxforum.net