---
name: "VistaIOEncodeAttrValue"
section: "3"
platform: "linux"
package: "libvistaio-dev"
version: "1.2.19-3+b2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/VistaIOEncodeAttrValue"
---

# VistaIOEncodeAttrValue(3)

encode an attribute value

## NAME

VistaIOEncodeAttrValue - encode an attribute value

## SYNOPSIS

```
VistaIOStringConst VistaIOEncodeAttrValue (dict, repn, value)
VistaIODictEntry *dict;
VistaIORepnKind repn;
type value;
```

**where** *type***, according to** *repn***, is VistaIOBit, VistaIOUByte,**  **VistaIOSByte, VistaIOShort, VistaIOLong, VistaIOFloat, VistaIODouble,**  **VistaIOBoolean, or VistaIOString.**

## ARGUMENTS

- *dict*

  **May specify a dictionary to be used in translating the value supplied** **to a keyword that should be returned as the encoded value, or it may be** **NULL**

- *repn*

  **Specifies the representation of the value to be encoded.**

- *value*

  **Specifies the value to be encoded.**

## DESCRIPTION

**VistaIOEncodeAttrValue takes a value and an optional dictionary, and**  **encodes the value as a character string suitable for storage in an**  **attribute list or output to a data file.**

**With the** *dict* **argument you can provide a dictionary for mapping**  *value* **to a keyword that will be returned as the encoded value (see**  **[VistaIOdictionary(3)](/VistaIOdictionary/3.md)). For example, if you pass a value of 1 and a**  **dictionary that associates the value 1 with the keyword ubyte (as the**  **dictionaryVistaIORepnDict does), then the string ubyte will be**  **returned. Dictionaries may be used to map both numeric values and strings**  **to keywords. If you supply a dictionary but** *value* **is not mentioned in**  **that dictionary, then** *value* **itself will be encoded as a string and** **returned.**

## RETURN VALUES

**If successful, VistaIOEncodeAttrValue returns a string that is valid until**  **the next VistaIOEncodeAttrValue, VistaIOSetAttr, or VistaIOSetAttrValue**  **call. If, on the other hand, it fails because** *repn* **is not one of the**  **representations supported, it returns**  **NULL**

## SEE ALSO

[**VistaIODecodeAttrValue**(3)](/VistaIODecodeAttrValue/3.md), [**VistaIOSetAttr**(3)](/VistaIOSetAttr/3.md), [**VistaIOattribute**(3)](/VistaIOattribute/3.md),

## DIAGNOSTICS

- \`\`Can't encode from *repn*.''

  **The** *repn* **argument is not one of VistaIOBitRepn, VistaIOUByteRepn, ...,** **VistaIOBooleanRepn, or VistaIOStringRepn.**

## AUTHOR

**Art Pope \<pope@cs.ubc.ca\>**

**Adaption to vistaio: Gert Wollny \<gw.fossdev@gmail.com\>**
