summaryrefslogtreecommitdiffstats
path: root/doc/binary.n
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-06-26 08:32:17 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-06-26 08:32:17 (GMT)
commit8fc811e066034462c225778dd4e2ca614a3e13c6 (patch)
tree9cd29fad95d009ec31c0fb02a7f432e2847b341b /doc/binary.n
parent6b55f89342181e459f07cee95f7ace98de336b9c (diff)
parentc4459402a9117b184d3ad0d2640628db19327ae4 (diff)
downloadtcl-8fc811e066034462c225778dd4e2ca614a3e13c6.zip
tcl-8fc811e066034462c225778dd4e2ca614a3e13c6.tar.gz
tcl-8fc811e066034462c225778dd4e2ca614a3e13c6.tar.bz2
Merge 8.6
Diffstat (limited to 'doc/binary.n')
-rw-r--r--doc/binary.n174
1 files changed, 87 insertions, 87 deletions
diff --git a/doc/binary.n b/doc/binary.n
index 77a4ec2..00b29d4 100644
--- a/doc/binary.n
+++ b/doc/binary.n
@@ -180,11 +180,11 @@ specified length, the extra characters will be ignored. If
then all of the bytes in \fIarg\fR will be
formatted. If \fIcount\fR is omitted, then one character will be
formatted. For example, the command:
-.RS
+.RS
.PP
.CS
\fBbinary format\fR a7a*a alpha bravo charlie
-.CE
+.CE
.PP
will return a binary string equivalent to:
.PP
@@ -196,7 +196,7 @@ the command:
.PP
.CS
\fBbinary format\fR a* [encoding convertto utf-8 \eu20ac]
-.CE
+.CE
.PP
will return a binary string equivalent to:
.PP
@@ -209,7 +209,7 @@ UTF-8 byte sequence for a Euro-currency character), and the command:
.PP
.CS
\fBbinary format\fR a* [encoding convertto iso8859-15 \eu20ac]
-.CE
+.CE
.PP
will return a binary string equivalent to:
.PP
@@ -219,11 +219,11 @@ will return a binary string equivalent to:
.PP
(which is the ISO
8859\-15 byte sequence for a Euro-currency character). Contrast these
-last two with:
+last two with:
.PP
.CS
\fBbinary format\fR a* \eu20ac
-.CE
+.CE
.PP
which returns a binary string equivalent to:
.PP
@@ -238,11 +238,11 @@ what is desired.
.IP \fBA\fR 5
This form is the same as \fBa\fR except that spaces are used for
padding instead of nulls. For example,
-.RS
+.RS
.PP
.CS
\fBbinary format\fR A6A*A alpha bravo charlie
-.CE
+.CE
.PP
will return
.PP
@@ -265,11 +265,11 @@ digits in \fIarg\fR will be formatted. If \fIcount\fR is omitted,
then one digit will be formatted. If the number of bits formatted
does not end at a byte boundary, the remaining bits of the last byte
will be zeros. For example,
-.RS
+.RS
.PP
.CS
\fBbinary format\fR b5b* 11100 111000011010
-.CE
+.CE
.PP
will return a binary string equivalent to:
.PP
@@ -280,11 +280,11 @@ will return a binary string equivalent to:
.IP \fBB\fR 5
This form is the same as \fBb\fR except that the bits are stored in
high-to-low order within each byte. For example,
-.RS
+.RS
.PP
.CS
\fBbinary format\fR B5B* 11100 111000011010
-.CE
+.CE
.PP
will return a binary string equivalent to:
.PP
@@ -307,11 +307,11 @@ then all of the digits in \fIarg\fR will be formatted. If
\fIcount\fR is omitted, then one digit will be formatted. If the
number of digits formatted does not end at a byte boundary, the
remaining bits of the last byte will be zeros. For example,
-.RS
+.RS
.PP
.CS
\fBbinary format\fR H3H*H2 ab DEF 987
-.CE
+.CE
.PP
will return a binary string equivalent to:
.PP
@@ -322,11 +322,11 @@ will return a binary string equivalent to:
.IP \fBh\fR 5
This form is the same as \fBH\fR except that the digits are stored in
low-to-high order within each byte. This is seldom required. For example,
-.RS
+.RS
.PP
.CS
\fBbinary format\fR h3h*h2 AB def 987
-.CE
+.CE
.PP
will return a binary string equivalent to:
.PP
@@ -344,11 +344,11 @@ are stored as a one-byte value at the cursor position. If \fIcount\fR is
then all of the integers in the list are formatted. If the
number of elements in the list is greater
than \fIcount\fR, then the extra elements are ignored. For example,
-.RS
+.RS
.PP
.CS
\fBbinary format\fR c3cc* {3 -3 128 1} 260 {2 5}
-.CE
+.CE
.PP
will return a binary string equivalent to:
.PP
@@ -356,11 +356,11 @@ will return a binary string equivalent to:
\fB\ex03\exfd\ex80\ex04\ex02\ex05\fR
.CE
.PP
-whereas:
+whereas:
.PP
.CS
\fBbinary format\fR c {2 5}
-.CE
+.CE
.PP
will generate an error.
.RE
@@ -370,11 +370,11 @@ This form is the same as \fBc\fR except that it stores one or more
low-order 16-bits of each integer are stored as a two-byte value at
the cursor position with the least significant byte stored first. For
example,
-.RS
+.RS
.PP
.CS
\fBbinary format\fR s3 {3 -3 258 1}
-.CE
+.CE
.PP
will return a binary string equivalent to:
.PP
@@ -386,11 +386,11 @@ will return a binary string equivalent to:
This form is the same as \fBs\fR except that it stores one or more
16-bit integers in big-endian byte order in the output string. For
example,
-.RS
+.RS
.PP
.CS
\fBbinary format\fR S3 {3 -3 258 1}
-.CE
+.CE
.PP
will return a binary string equivalent to:
.PP
@@ -410,11 +410,11 @@ This form is the same as \fBc\fR except that it stores one or more
low-order 32-bits of each integer are stored as a four-byte value at
the cursor position with the least significant byte stored first. For
example,
-.RS
+.RS
.PP
.CS
\fBbinary format\fR i3 {3 -3 65536 1}
-.CE
+.CE
.PP
will return a binary string equivalent to:
.PP
@@ -426,11 +426,11 @@ will return a binary string equivalent to:
This form is the same as \fBi\fR except that it stores one or more one
or more 32-bit integers in big-endian byte order in the output string.
For example,
-.RS
+.RS
.PP
.CS
\fBbinary format\fR I3 {3 -3 65536 1}
-.CE
+.CE
.PP
will return a binary string equivalent to:
.PP
@@ -451,11 +451,11 @@ This form is the same as \fBc\fR except that it stores one or more
low-order 64-bits of each integer are stored as an eight-byte value at
the cursor position with the least significant byte stored first. For
example,
-.RS
+.RS
.PP
.CS
\fBbinary format\fR w 7810179016327718216
-.CE
+.CE
.PP
will return the binary string \fBHelloTcl\fR.
.RE
@@ -463,11 +463,11 @@ will return the binary string \fBHelloTcl\fR.
This form is the same as \fBw\fR except that it stores one or more one
or more 64-bit integers in big-endian byte order in the output string.
For example,
-.RS
+.RS
.PP
.CS
\fBbinary format\fR Wc 4785469626960341345 110
-.CE
+.CE
.PP
will return the binary string \fBBigEndian\fR
.RE
@@ -491,11 +491,11 @@ as defined by the system will be used instead. Because Tcl uses
double-precision floating point numbers internally, there may be some
loss of precision in the conversion to single-precision. For example,
on a Windows system running on an Intel Pentium processor,
-.RS
+.RS
.PP
.CS
\fBbinary format\fR f2 {1.6 3.4}
-.CE
+.CE
.PP
will return a binary string equivalent to:
.PP
@@ -517,11 +517,11 @@ This form is the same as \fBf\fR except that it stores one or more one
or more double-precision floating point numbers in the machine's native
representation in the output string. For example, on a
Windows system running on an Intel Pentium processor,
-.RS
+.RS
.PP
.CS
\fBbinary format\fR d1 {1.6}
-.CE
+.CE
.PP
will return a binary string equivalent to:
.PP
@@ -544,11 +544,11 @@ not specified, stores one null byte. If \fIcount\fR is
.QW \fB*\fR ,
generates an error. This type does not consume an argument. For
example,
-.RS
+.RS
.PP
.CS
\fBbinary format\fR a3xa3x2a3 abc def ghi
-.CE
+.CE
.PP
will return a binary string equivalent to:
.PP
@@ -565,11 +565,11 @@ then the cursor is positioned at location 0 so that the next byte
stored will be the first byte in the result string. If \fIcount\fR is
omitted then the cursor is moved back one byte. This type does not
consume an argument. For example,
-.RS
+.RS
.PP
.CS
\fBbinary format\fR a3X*a3X2a3 abc def ghi
-.CE
+.CE
.PP
will return \fBdghi\fR.
.RE
@@ -584,11 +584,11 @@ locations and the cursor will be placed at the specified location. If
then the cursor is moved to the current end of
the output string. If \fIcount\fR is omitted, then an error will be
generated. This type does not consume an argument. For example,
-.RS
+.RS
.PP
.CS
\fBbinary format\fR a5@2a1@*a3@10a1 abcde f ghi j
-.CE
+.CE
.PP
will return
.PP
@@ -631,7 +631,7 @@ is accepted for all field types but is ignored for non-integer fields.
.PP
A similar example as with \fBbinary format\fR should explain the
relation between field specifiers and arguments in case of the binary
-scan subcommand:
+scan subcommand:
.PP
.CS
\fBbinary scan\fR $bytes s3s first second
@@ -643,15 +643,15 @@ is long enough) assigns a list of three integers to the variable
If \fIbytes\fR contains fewer than 8 bytes (i.e. four 2-byte
integers), no assignment to \fIsecond\fR will be made, and if
\fIbytes\fR contains fewer than 6 bytes (i.e. three 2-byte integers),
-no assignment to \fIfirst\fR will be made. Hence:
+no assignment to \fIfirst\fR will be made. Hence:
.PP
.CS
puts [\fBbinary scan\fR abcdefg s3s first second]
puts $first
puts $second
-.CE
+.CE
.PP
-will print (assuming neither variable is set previously):
+will print (assuming neither variable is set previously):
.PP
.CS
1
@@ -663,17 +663,17 @@ It is \fIimportant\fR to note that the \fBc\fR, \fBs\fR, and \fBS\fR
(and \fBi\fR and \fBI\fR on 64bit systems) will be scanned into
long data size values. In doing this, values that have their high
bit set (0x80 for chars, 0x8000 for shorts, 0x80000000 for ints),
-will be sign extended. Thus the following will occur:
+will be sign extended. Thus the following will occur:
.PP
.CS
set signShort [\fBbinary format\fR s1 0x8000]
\fBbinary scan\fR $signShort s1 val; \fI# val == 0xFFFF8000\fR
-.CE
+.CE
.PP
If you require unsigned values you can include the
.QW u
flag character following
-the field type. For example, to read an unsigned short value:
+the field type. For example, to read an unsigned short value:
.PP
.CS
set signShort [\fBbinary format\fR s1 0x8000]
@@ -695,30 +695,30 @@ range \eu0000-\eu00ff so the \fBencoding convertfrom\fR command will be
needed if the string is not a binary string or a string encoded in ISO
8859\-1.
For example,
-.RS
+.RS
.PP
.CS
\fBbinary scan\fR abcde\e000fghi a6a10 var1 var2
-.CE
+.CE
.PP
will return \fB1\fR with the string equivalent to \fBabcde\e000\fR
-stored in \fIvar1\fR and \fIvar2\fR left unmodified, and
+stored in \fIvar1\fR and \fIvar2\fR left unmodified, and
.PP
.CS
\fBbinary scan\fR \e342\e202\e254 a* var1
set var2 [encoding convertfrom utf-8 $var1]
-.CE
+.CE
.PP
will store a Euro-currency character in \fIvar2\fR.
.RE
.IP \fBA\fR 5
This form is the same as \fBa\fR, except trailing blanks and nulls are stripped from
the scanned value before it is stored in the variable. For example,
-.RS
+.RS
.PP
.CS
\fBbinary scan\fR "abc efghi \e000" A* var1
-.CE
+.CE
.PP
will return \fB1\fR with \fBabc efghi\fR stored in \fIvar1\fR.
.RE
@@ -734,11 +734,11 @@ bits in the last byte are ignored. If \fIcount\fR is
.QW \fB*\fR ,
then all of the remaining bits in \fIstring\fR will be scanned. If
\fIcount\fR is omitted, then one bit will be scanned. For example,
-.RS
+.RS
.PP
.CS
\fBbinary scan\fR \ex07\ex87\ex05 b5b* var1 var2
-.CE
+.CE
.PP
will return \fB2\fR with \fB11100\fR stored in \fIvar1\fR and
\fB1110000110100000\fR stored in \fIvar2\fR.
@@ -746,11 +746,11 @@ will return \fB2\fR with \fB11100\fR stored in \fIvar1\fR and
.IP \fBB\fR 5
This form is the same as \fBb\fR, except the bits are taken in
high-to-low order within each byte. For example,
-.RS
+.RS
.PP
.CS
\fBbinary scan\fR \ex70\ex87\ex05 B5B* var1 var2
-.CE
+.CE
.PP
will return \fB2\fR with \fB01110\fR stored in \fIvar1\fR and
\fB1000011100000101\fR stored in \fIvar2\fR.
@@ -766,11 +766,11 @@ byte. Any extra bits in the last byte are ignored. If \fIcount\fR is
then all of the remaining hex digits in \fIstring\fR will be
scanned. If \fIcount\fR is omitted, then one hex digit will be
scanned. For example,
-.RS
+.RS
.PP
.CS
\fBbinary scan\fR \ex07\exC6\ex05\ex1f\ex34 H3H* var1 var2
-.CE
+.CE
.PP
will return \fB2\fR with \fB07c\fR stored in \fIvar1\fR and
\fB051f34\fR stored in \fIvar2\fR.
@@ -778,11 +778,11 @@ will return \fB2\fR with \fB07c\fR stored in \fIvar1\fR and
.IP \fBh\fR 5
This form is the same as \fBH\fR, except the digits are taken in
reverse (low-to-high) order within each byte. For example,
-.RS
+.RS
.PP
.CS
\fBbinary scan\fR \ex07\ex86\ex05\ex12\ex34 h3h* var1 var2
-.CE
+.CE
.PP
will return \fB2\fR with \fB706\fR stored in \fIvar1\fR and
\fB502143\fR stored in \fIvar2\fR.
@@ -798,11 +798,11 @@ immediately after the \fBc\fR. If \fIcount\fR is
then all of the remaining bytes in \fIstring\fR will be scanned. If
\fIcount\fR is omitted, then one 8-bit integer will be scanned. For
example,
-.RS
+.RS
.PP
.CS
\fBbinary scan\fR \ex07\ex86\ex05 c2c* var1 var2
-.CE
+.CE
.PP
will return \fB2\fR with \fB7 -122\fR stored in \fIvar1\fR and \fB5\fR
stored in \fIvar2\fR. Note that the integers returned are signed unless
@@ -817,11 +817,11 @@ the corresponding variable as a list. If \fIcount\fR is
then all of the remaining bytes in \fIstring\fR will be scanned. If
\fIcount\fR is omitted, then one 16-bit integer will be scanned. For
example,
-.RS
+.RS
.PP
.CS
\fBbinary scan\fR \ex05\ex00\ex07\ex00\exf0\exff s2s* var1 var2
-.CE
+.CE
.PP
will return \fB2\fR with \fB5 7\fR stored in \fIvar1\fR and \fB\-16\fR
stored in \fIvar2\fR. Note that the integers returned are signed unless
@@ -831,11 +831,11 @@ stored in \fIvar2\fR. Note that the integers returned are signed unless
This form is the same as \fBs\fR except that the data is interpreted
as \fIcount\fR 16-bit integers represented in big-endian byte
order. For example,
-.RS
+.RS
.PP
.CS
\fBbinary scan\fR \ex00\ex05\ex00\ex07\exff\exf0 S2S* var1 var2
-.CE
+.CE
.PP
will return \fB2\fR with \fB5 7\fR stored in \fIvar1\fR and \fB\-16\fR
stored in \fIvar2\fR.
@@ -856,12 +856,12 @@ the corresponding variable as a list. If \fIcount\fR is
then all of the remaining bytes in \fIstring\fR will be scanned. If
\fIcount\fR is omitted, then one 32-bit integer will be scanned. For
example,
-.RS
+.RS
.PP
.CS
set str \ex05\ex00\ex00\ex00\ex07\ex00\ex00\ex00\exf0\exff\exff\exff
\fBbinary scan\fR $str i2i* var1 var2
-.CE
+.CE
.PP
will return \fB2\fR with \fB5 7\fR stored in \fIvar1\fR and \fB\-16\fR
stored in \fIvar2\fR. Note that the integers returned are signed unless
@@ -872,12 +872,12 @@ This form is the same as \fBI\fR except that the data is interpreted
as \fIcount\fR 32-bit signed integers represented in big-endian byte
order, or as unsigned if \fBu\fR is placed
immediately after the \fBI\fR. For example,
-.RS
+.RS
.PP
.CS
set str \ex00\ex00\ex00\ex05\ex00\ex00\ex00\ex07\exff\exff\exff\exf0
\fBbinary scan\fR $str I2I* var1 var2
-.CE
+.CE
.PP
will return \fB2\fR with \fB5 7\fR stored in \fIvar1\fR and \fB\-16\fR
stored in \fIvar2\fR.
@@ -898,12 +898,12 @@ the corresponding variable as a list. If \fIcount\fR is
then all of the remaining bytes in \fIstring\fR will be scanned. If
\fIcount\fR is omitted, then one 64-bit integer will be scanned. For
example,
-.RS
+.RS
.PP
.CS
set str \ex05\ex00\ex00\ex00\ex07\ex00\ex00\ex00\exf0\exff\exff\exff
\fBbinary scan\fR $str wi* var1 var2
-.CE
+.CE
.PP
will return \fB2\fR with \fB30064771077\fR stored in \fIvar1\fR and
\fB\-16\fR stored in \fIvar2\fR.
@@ -913,12 +913,12 @@ This form is the same as \fBw\fR except that the data is interpreted
as \fIcount\fR 64-bit signed integers represented in big-endian byte
order, or as unsigned if \fBu\fR is placed
immediately after the \fBW\fR. For example,
-.RS
+.RS
.PP
.CS
set str \ex00\ex00\ex00\ex05\ex00\ex00\ex00\ex07\exff\exff\exff\exf0
\fBbinary scan\fR $str WI* var1 var2
-.CE
+.CE
.PP
will return \fB2\fR with \fB21474836487\fR stored in \fIvar1\fR and \fB\-16\fR
stored in \fIvar2\fR.
@@ -944,11 +944,11 @@ bytes that are scanned may vary. If the data does not represent a
valid floating point number, the resulting value is undefined and
compiler dependent. For example, on a Windows system running on an
Intel Pentium processor,
-.RS
+.RS
.PP
.CS
\fBbinary scan\fR \ex3f\excc\excc\excd f var1
-.CE
+.CE
.PP
will return \fB1\fR with \fB1.6000000238418579\fR stored in
\fIvar1\fR.
@@ -968,11 +968,11 @@ This form is the same as \fBf\fR except that the data is interpreted
as \fIcount\fR double-precision floating point numbers in the
machine's native representation. For example, on a Windows system
running on an Intel Pentium processor,
-.RS
+.RS
.PP
.CS
\fBbinary scan\fR \ex9a\ex99\ex99\ex99\ex99\ex99\exf9\ex3f d var1
-.CE
+.CE
.PP
will return \fB1\fR with \fB1.6000000000000001\fR
stored in \fIvar1\fR.
@@ -996,11 +996,11 @@ current cursor position, then the cursor is positioned after
the last byte in \fIstring\fR. If \fIcount\fR is omitted, then the
cursor is moved forward one byte. Note that this type does not
consume an argument. For example,
-.RS
+.RS
.PP
.CS
\fBbinary scan\fR \ex01\ex02\ex03\ex04 x2H* var1
-.CE
+.CE
.PP
will return \fB1\fR with \fB0304\fR stored in \fIvar1\fR.
.RE
@@ -1013,11 +1013,11 @@ then the cursor is positioned at location 0 so that the next byte
scanned will be the first byte in \fIstring\fR. If \fIcount\fR
is omitted then the cursor is moved back one byte. Note that this
type does not consume an argument. For example,
-.RS
+.RS
.PP
.CS
\fBbinary scan\fR \ex01\ex02\ex03\ex04 c2XH* var1 var2
-.CE
+.CE
.PP
will return \fB2\fR with \fB1 2\fR stored in \fIvar1\fR and \fB020304\fR
stored in \fIvar2\fR.
@@ -1028,11 +1028,11 @@ by \fIcount\fR. Note that position 0 refers to the first byte in
\fIstring\fR. If \fIcount\fR refers to a position beyond the end of
\fIstring\fR, then the cursor is positioned after the last byte. If
\fIcount\fR is omitted, then an error will be generated. For example,
-.RS
+.RS
.PP
.CS
\fBbinary scan\fR \ex01\ex02\ex03\ex04 c2@1H* var1 var2
-.CE
+.CE
.PP
will return \fB2\fR with \fB1 2\fR stored in \fIvar1\fR and \fB020304\fR
stored in \fIvar2\fR.