<?xml version="1.0"?>

<proj>

<title>encdec</title>
<short>Encode and decode a wide range of C objects</short>
<desc>
This module may be used to encode and decode C objects such  as  integers, floats, doubles, times, and internationalized strings to and from a wide variety of binary formats as they might appear in portable file formats or network messages.  These  encodings  include  16, 34, and 64 bit big and little endian intergers, big and little endian IEEE754  float  and  double  values,  6  time encodings,  and  the wide range of string encodings supported by libiconv. The functions are all designed to be ideal for in-situ decoding  and  encoding  of complex formats. The code is licensed under the GNU Library General Public License.
<p/>
<i>Why not just use XDR?</i>
<p/>
XDR is a specific format. The encdec functions are ideal for picking apart and building arbitrary encodings like binary file formats and network messages. Like XDR, it can be used very effectively to implement custom RPCs but that is incedental. XDR is also not available in certain environments like Java ironically. In this case encdec's open ended encoding/decoding capabilities could be used with whatever the peer encoder/decoder has available (e.g. <tt>DataInputStream</tt> and <tt>DataOutputStream</tt>).
<p/>
<i>How do encdec's string functions differ from iconv?</i>
<p/>
The encdec mbs functions are just a different interface into Bruno Haible's libiconv. They are more convenient for in-situ string manipulation.
<p/>
For example, if you are given a string that you need to convert to the locale encoding (e.g. UTF-8) but you do not know how much memory the resulting string will occupy, something like the following code example could be used. It passes a NULL destination buffer to indicate to the <a href="dl/docs/ref/encdec.html#dec_mbsncpy"><tt>dec_mbsncpy</tt></a> function that the exact number of bytes required to encode the resulting string should be returned. This value is used to allocate the correct amount of memory and the string is converted again with the <tt>dec_mbsncpy</tt> function but this time with the allocate memory instead of NULL:
<pre>

  if ((n = dec_mbsncpy(&amp;src, sn, NULL, -1, -1, "KOI8-R")) == (size_t)-1) {
      perror("Failed to determine required buf size");
      return -1;
  }
  
  buf = malloc(n);
  
  if (!buf || (n = dec_mbsncpy(&amp;src, sn, buf, n, -1, "KIO8-R")) == (size_t)-1) {
      perror("Failed to convert string");
      return -1;
  }
  // buf is now the decoded string

</pre>
</desc>

<links>

<a href="dl/">Download</a>
<a href="dl/docs/ref/ref.html">API Reference</a>
<a href="dl/src/">Browse The Source</a>

</links>
<news>

<!-- entry>
<title></title>
<sub></sub>
<desc></desc>
</entry-->

<entry>
<title>encdec-0.4.0 released</title>
<sub>Tue Jul 22, 2003</sub>
<desc>
An <a href="dl/src/Encdec.java">Encdec</a> Java class has been added to the package. The static methods in this class mirrot the C API. The encodings generated by both implementations are identical (except for a loss in precision with time encodings because C's <tt>time_t</tt> has a 1 second resolution vs. Java's millisecond resolution). This package should be ideal for reading and writing binary data between Java and C processes possibly over a network.
</desc>
</entry>

<entry>
<title>encdec-0.3.7 released</title>
<sub>Sat Mar 21, 2003</sub>
<desc>
The prototypes for float and double functions did not specify <tt>unsigned char</tt> <tt>src</tt> and <tt>dst</tt> parameters. This is technically incorrect and has been fixed. The documentation has also been enhanced to use the latest CStyleX package (Tip: in Mozilla you can use Ctrl+ and Ctrl- to increase and decrease the text size).
</desc>
</entry>

<entry>
<title>encdec-0.3.6 released</title>
<sub>Sat Nov 16, 2002</sub>
<desc>
IEEE754 functions have been added, a popular Windows time encoding has been added, and portability has been greatly improved (pretty much anywhere including Win32).
</desc>
</entry>

<entry>
<title>CStyleX Documentation</title>
<sub>Sat Nov 16, 2002</sub>
<desc>
An API reference, a man page, and this project page have been generated using the <a href="http://www.ioplex.com/~miallen/cstylex/">CStyleX</a> package.
</desc>
</entry>

<entry>
<title>encdec-0.2.3 released</title>
<sub>Fri Mar 22, 2002</sub>
<desc>
The <a href="dl/docs/ref/encdec.html"><tt>FLD</tt></a> macro for decoding bit fields has been reduced to a trivial and rather interesting expression.</desc>
</entry>

<entry>
<title>encdec-0.2.2 released</title>
<sub>Thu Mar 14, 2002</sub>
<desc>
The <tt>dec_mbsncpy_new</tt> and <tt>dec_mbscpy_new</tt> function names have been changed to <tt>dec_mbsndup</tt> and <tt>dec_mbsdup</tt> to be more consistent with common C practice.
</desc>
</entry>

</news>
</proj>


