---
name: "gd_encoding"
section: "3"
platform: "linux"
package: "libgetdata-doc"
version: "0.11.0-15"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/gd_encoding"
---

# gd\_encoding(3)

report the binary encoding of data in a Dirfile

## NAME

gd\_encoding — report the binary encoding of data in a Dirfile

## SYNOPSIS

**#include \<getdata.h\>**

**unsigned long gd\_encoding(DIRFILE \****dirfile***, int** *fragment\_index***);**

## DESCRIPTION

The **gd\_encoding**() function queries a [dirfile(5)](/dirfile/5.md) database specified by *dirfile* and returns the data encoding for the fragment indexed by *fragment\_index*. The data encoding of a fragment indicate the encoding of data files associated with **RAW** fields defined in the specified fragment.  The encoding of a fragment containing no **RAW** fields is ignored.

## RETURN VALUE

Upon successful completion, **gd\_encoding**() returns the binary encoding of the specified fragment, which will one of the following symbols:

-

  **GD\_UNENCODED**, **GD\_BZIP2\_ENCODED**, **GD\_FLAC\_ENCODED**, **GD\_GZIP\_ENCODED**, **GD\_LZMA\_ENCODED**, **GD\_SIE\_ENCODED**, **GD\_SLIM\_ENCODED**, **GD\_TEXT\_ENCODED**, **GD\_ZZIP\_ENCODED**, **GD\_ZZSLIM\_ENCODED**, **GD\_ENC\_UNSUPPORTED**.

If the encoding scheme specified in the dirfile metadata is unknown to GetData, **GD\_ENC\_UNSUPPORTED** will be returned.  See [**gd\_open**(3)](/gd_open/3.md) and [dirfile-encoding(5)](/dirfile-encoding/5.md) for the meanings of the other symbols and details on the supported encoding schemes.

On error, this function returns zero and stores a negative-valued error code in the **DIRFILE** object which may be retrieved by a subsequent call to [**gd\_error**(3)](/gd_error/3.md). Possible error codes are:\
  .TP 8 **GD\_E\_BAD\_DIRFILE** The supplied dirfile was invalid.\
  .TP 8 **GD\_E\_BAD\_INDEX** The supplied index was out of range.

A descriptive error string for the error may be obtained by calling [**gd\_error\_string**(3)](/gd_error_string/3.md).

## HISTORY

The **get\_encoding**() function appeared in GetData-0.5.0.

In GetData-0.7.0, this function was renamed to **gd\_encoding**().

## SEE ALSO

[**gd\_alter\_encoding**(3)](/gd_alter_encoding/3.md), [**gd\_error**(3)](/gd_error/3.md), [**gd\_error\_string**(3)](/gd_error_string/3.md), [**gd\_getdata**(3)](/gd_getdata/3.md), [**gd\_open**(3)](/gd_open/3.md), [dirfile(5)](/dirfile/5.md), [dirfile-encoding(5)](/dirfile-encoding/5.md)
