Package: glib

Type glib:unichar

Details

The g:unichar type specifier represents the C gunichar type which can hold any UCS-4 character code. The g:unichar type specifier performs automatic conversion from the C gunichar type to a Lisp character and a Lisp character to the C type. An integer as argument to the cffi:convert-to-foreign function is passed through.

Examples

Convert a Lisp character to a C gunichar value:
(cffi:convert-to-foreign #A 'g:unichar) => 65
(cffi:convert-to-foreign #0 'g:unichar) => 48
(cffi:convert-to-foreign #return 'g:unichar) => 13
(cffi:convert-to-foreign #space 'g:unichar) => 32    
Convert a C gunichar value to a Lisp character:
(cffi:convert-from-foreign 65 'g:unichar) => #A
(cffi:convert-from-foreign 48 'g:unichar) => #0
(cffi:convert-from-foreign 13 'g:unichar) => #return
(cffi:convert-from-foreign 32 'g:unichar) => #space    
An integer argument is passed through:
(cffi:convert-to-foreign 65 'g:unichar) => 65    
2024-10-12