---
name: "curs_getcchar"
section: "3x"
platform: "macos"
package: "ncurses"
version: "79"
release: "macOS 26.5"
platforms: ["linux", "macos"]
url: "https://new.carta.tech/curs_getcchar/3x"
---

# curs\_getcchar(3x)

Get a wide character string and rendition from a cchar\_t or set a cchar\_t from a wide-character string

## NAME

**getcchar**, **setcchar** - Get a wide character string and rendition from a **cchar\_t** or set a **cchar\_t** from a wide-character string

## SYNOPSIS

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

**int getcchar(**\
         **const cchar\_t \**wcval*,**\
         **wchar\_t \**wch*,**\
         **attr\_t \**attrs*,**\
         **short \**color\_pair*,**\
         **void \**opts* );**

**int setcchar(**\
         **cchar\_t \**wcval*,**\
         **const wchar\_t \**wch*,**\
         **const attr\_t *attrs*,**\
         **short *color\_pair*,**\
         **void \**opts* );**

## DESCRIPTION

### getcchar

The **getcchar** function gets a wide-character string and rendition from a **cchar\_t** argument. When *wch* is not a null pointer, the **getcchar** function does the following:

- •

  Extracts information from a **cchar\_t** value *wcval*

- •

  Stores the character attributes in the location pointed to by *attrs*

- •

  Stores the color-pair in the location pointed to by *color\_pair*

- •

  Stores the wide-character string, characters referenced by *wcval*, into the array pointed to by *wch*.

When *wch* is a null pointer, the **getcchar** function does the following:

- •

  Obtains the number of wide characters pointed to by *wcval*

- •

  Does not change the data referenced by *attrs* or *color\_pair*

### setcchar

The **setcchar** function initializes the location pointed to by *wcval* by using:

- •

  The character attributes in *attrs*

- •

  The color pair in *color\_pair*

- •

  The wide-character string pointed to by *wch*. The string must be L'\\0' terminated, contain at most one spacing character, which must be the first.

-

  Up to **CCHARW\_MAX**-1 nonspacing characters may follow. Additional nonspacing characters are ignored.

-

  The string may contain a single control character instead. In that case, no nonspacing characters are allowed.

## NOTES

The *opts* argument is reserved for future use. Currently, an application must provide a null pointer as *opts*.

The *wcval* argument may be a value generated by a call to **setcchar** or by a function that has a **cchar\_t** output argument. If *wcval* is constructed by any other means, the effect is unspecified.

## RETURN VALUE

When *wch* is a null pointer, **getcchar** returns the number of wide characters referenced by *wcval*, including one for a trailing null.

When *wch* is not a null pointer, **getcchar** returns **OK** upon successful completion, and **ERR** otherwise.

Upon successful completion, **setcchar** returns **OK**. Otherwise, it returns **ERR**.

## SEE ALSO

Functions: **curs\_attr**(3X), **curs\_color**(3X), **curses**(3X), [**wcwidth**(3)](/wcwidth/3.md).
