> For the complete documentation index, see [llms.txt](https://sandbox-docs.verifone.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sandbox-docs.verifone.com/adk-5.0-programmers-guide/readme/files/dir_44d926a17fc606d3c25449ba60427c63/dir_048f823fee1bfb22502a8732b9a001aa/util_8cpp.md).

# util.cpp

[Functions](#func-members)

`#include <stdio.h>` `#include <stdlib.h>` `#include <string.h>` `#include <regex.h>` `#include <`[hexutil.h](/adk-5.0-programmers-guide/sdi_2src_2hexutil_8h_source.md)`>` `#include "`[util.h](/adk-5.0-programmers-guide/sdi_2src_2util_8h_source.md)`"` `#include "`[\_logf.h](/adk-5.0-programmers-guide/__logf_8h_source.md)`"` `#include "`[sys.h](/adk-5.0-programmers-guide/sys_8h_source.md)`"` `#include "config/sdi_sysconfig.h"`

Include dependency graph for util.cpp:

![](/files/kV0pVV6lK4X5FonF6GvO)

|               |                                                                                                                                                     |
| ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| Functions     |                                                                                                                                                     |
| bool          | [getForceCurrAbbr](#ad052d8032bf71a0869d0eccdf4a7c6c5) (unsigned short currency)                                                                    |
| const char \* | [getCurrencyName](#af8e537859d3bd237614e1f416351cdbe) (unsigned short currency)                                                                     |
| short         | [getCurrencyExponent](#a747e0b130dd6c037d12411a173843e0d) (unsigned short currency)                                                                 |
| int           | [verifyDate](#ab29fd00cd12931bf70c259be8569ed35) (const char \*date, const char \*format)                                                           |
| int           | [bcdValid](#a5d38a0b4222458e86fffe40d3101ff4a) (const unsigned char \*a, unsigned size)                                                             |
| string        | [bcdToAmountStr](#a41542e6c6f279dab1d218a7f1f66e9b3) (const unsigned char \*bcd, unsigned size, unsigned pos, const string dsep, const string tsep) |
| bool          | [matchRegex](#a38e7c6dca4df24149a7c53b66d62a6ab) (const char \*str, const char \*\_regex)                                                           |
| string        | [escapeRegex](#a4c8a23387bc04abfd2451af2f2771bf5) (const string \&str)                                                                              |

### FunctionDocumentation <a href="#function-documentation" id="function-documentation"></a>

### bcdToAmountStr() <a href="#a41542e6c6f279dab1d218a7f1f66e9b3" id="a41542e6c6f279dab1d218a7f1f66e9b3"></a>

string bcdToAmountStr

### bcdValid() <a href="#a5d38a0b4222458e86fffe40d3101ff4a" id="a5d38a0b4222458e86fffe40d3101ff4a"></a>

int bcdValid

check if data is a valid BCD number

**Parameters**

\[in] **a** pointer to data \[in] **size** size of the buffer data points to

#### Returns

1 if it is a valid BCD number, 0 else

### escapeRegex() <a href="#a4c8a23387bc04abfd2451af2f2771bf5" id="a4c8a23387bc04abfd2451af2f2771bf5"></a>

string escapeRegex

### getCurrencyExponent() <a href="#a747e0b130dd6c037d12411a173843e0d" id="a747e0b130dd6c037d12411a173843e0d"></a>

short getCurrencyExponent

returns the currency exponent for the corresponding currency code. If the currency code is unknown or not supported, -1 returned.

**Parameters**

\[in] **currency** currency code

#### Returns

currency exponent or -1, if code is unknown

### getCurrencyName() <a href="#af8e537859d3bd237614e1f416351cdbe" id="af8e537859d3bd237614e1f416351cdbe"></a>

const char\\\* getCurrencyName

returns the currency name for the corresponding currency code. If the currency code is unknown or not supported, an empty string is returned.

**Parameters**

\[in] **currency** currency code

#### Returns

currency name as C-string or an empty string, if code is unknown

### getForceCurrAbbr() <a href="#ad052d8032bf71a0869d0eccdf4a7c6c5" id="ad052d8032bf71a0869d0eccdf4a7c6c5"></a>

bool getForceCurrAbbr

### matchRegex() <a href="#a38e7c6dca4df24149a7c53b66d62a6ab" id="a38e7c6dca4df24149a7c53b66d62a6ab"></a>

bool matchRegex

### verifyDate() <a href="#ab29fd00cd12931bf70c259be8569ed35" id="ab29fd00cd12931bf70c259be8569ed35"></a>

int verifyDate

Verify date

**Parameters**

\[in] **date** Pointer to date buffer \[in] **format** Pointer to format buffer

#### Returns

1 if date is valid, else 0

{% hint style="info" %}
Two-digit year values are interpreted as 2000...2099 Four-digit year values must be at least 1776 (the date of the global introduction of the Gregorian calendar)
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://sandbox-docs.verifone.com/adk-5.0-programmers-guide/readme/files/dir_44d926a17fc606d3c25449ba60427c63/dir_048f823fee1bfb22502a8732b9a001aa/util_8cpp.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
