cv in_pat out_pat [[infile] outfile]
CV(1)
NAME
cv - convert binary data files between representation formats
On this page
SYNOPSIS
DESCRIPTION
cv converts a stream of binary numbers from one representation
(format) to another, reading from infile and writing the converted
result to outfile. Each format is described by a short pattern (no
embedded blanks) drawn from the choices [h|n][s|u][c|s|i|l|d|8|16|32|64]:
-
h or n: Host-specific (h) or network-independent (n) byte order. Host format uses the native number representation and byte ordering of the machine running cv. Network format is big-endian, two’s complement; network doubles are 64-bit IEEE 754 in big-endian order. When omitted, network format is assumed.
-
s or u: Signed (s) or unsigned (u) integer. This flag has no effect on the double-precision format. When omitted, signed format is assumed.
-
c, s, i, l, d: C language types
char,short,int,long, anddouble, sized as on the host processor. -
8, 16, 32, 64: Explicit bit sizes, typically paired with n to specify exact data sizes regardless of host word length.
For example, hui is a host unsigned int and nl is a network
(signed) long. cv refuses to send binary output to a terminal.
OPTIONS
- in_pat
-
Format pattern of the input data. An empty string (
"") defaults tohuc(host unsigned char). - out_pat
-
Format pattern of the output data. An empty string (
"") defaults tonuc(network unsigned char). - infile
-
File to read input from. When both infile and outfile are given, this is the first filename; with a single filename it is the input and output goes to standard output. If omitted entirely, standard input is used.
- outfile
-
File to write the converted data to. Present only when two filenames are supplied; otherwise output goes to standard output.
EXAMPLES
cv hss n32 data.short data.net
Reads the binary file data.short of machine-specific signed shorts and
writes network-independent 32-bit integers to data.net, producing a
portable file that can be read identically on any platform.
cat data.nd | cv nd hd > data.hd
Reads network-independent double-precision floats from standard input and emits host-native doubles on standard output, the typical first step before feeding the values to a program that expects local byte order.
SEE ALSO
brlcad(1), dpix-pix(1), pix-bw(1), bw-pix(1)
-
J. Muuss, Workstations, Networking, Distributed Graphics, and Parallel Processing in Computer Graphics Techniques: Theory and Practice, edited by D. F. Rogers, R. A. Earnshaw, Springer-Verlag, 1990
AUTHOR
BRL-CAD Team
COPYRIGHT
This software is Copyright (c) 1991-2026 by the United States Government as represented by U.S. Army Research Laboratory.
BUG REPORTS
Reports of bugs or problems should be submitted via electronic mail to devs@brlcad.org