# Handling of UUI Data

VoiceGenie supports both ASCII and binary UUI data. This is done by using a URL encoding/decoding algorithm on UUI data being passed in to the platform with an inbound call, or sent out with an outbound call.

- Passing In UUI Data
- Sending Out UUI Data
- Conversion Example

Passing In UUI Data

When data is passed in to the platform with an inbound call (i.e., in the call setup message), the algorithm encodes non-ASCII bytes as "%HH", where "H" is a hexadecimal number and "%" is the escape. For example, "00000001" is represented as "%01", and "00001010" is represented as "%0A".

This will affect the data that is accessible in the VoiceXML page through a session variable (`session.telephone.uui`, `session.connection.uui`, `session.telephone.aai`, or `session.connection.aai`, depending on how the platform is configured).

Sending Out UUI Data

When data is sent out with an outbound call request, the algorithm decodes any "%HH" sequences into binary data. Except for "%", all other printable ASCII characters in the data remain unchanged.

This will affect the data that is sent out through the `aai`/`aaiexpr` attributes of `<transfer>` or `<call>`, or through the 'uuidata' property of an object passed through the `signalvar` attribute of `<transfer>` or `<call>`.

Conversion Example

The ECMAScript `parseInt()` function can be used to turn hexadecimal strings back into a decimal number. So binary data within an inbound UUI message can be accessed in the VoiceXML page with code like:

    <var name="uui" expr="session.telephone.uui"/>
    <var name="char1" expr="uui.charAt(0)"/>
    <!-- uui.charAt(1) == "%" -->
    <var name="byte1" expr="parseInt(uui.substring(2, 4), 16)"/>
    <!-- uui.charAt(4) == "%" -->
    <var name="byte2" expr="parseInt(uui.substring(5, 7), 16)"/>

(where the second parameter of `parseInt()` indicates that the string is in base 16). Then, if the binary value of the second field was "00000001", the `byte1` variable would be set to "1".