[BRLTTY] Special char and brlapi

Samuel Thibault samuel.thibault at ens-lyon.org
Wed May 18 08:49:36 EDT 2016


Hello,

Tayky, on Wed 18 May 2016 14:41:07 +0200, wrote:
> 1: When I use the function brlapi_writeText() for display a simple message, ok no problem.
> But when I write a special message with special char like "é", "ç", ...
> brlapi error, the size of paquet is too large.
> Do you have a solution ?

You probably have an encoding issue.  Did you use setlocale() to specify
the charset that your program uses?  See man brlapi_writeText:

“The text is assumed to be in the current locale charset, or latin1
if locales have not been initialized.  To initialize locales, use
setlocale(3).”

> 2: I use brlapi_readKey(), But I want to use a macro for call a Key for all device.
> exemple:
> c: 
> if (KEY_LEFT == brlapi_readKey())
> printf("ok\n");

You mean that you don't like that the code is returned through a pointer
rather than returned? Well you can write this:

static inline brlapi_keyCode_t mybrlapi_readKey(void) {
	brlapi_keyCode_t code;
	if (brlapi_readKey(1, &code) <= 0)
	{
		fprintf(stderr,"readkey error");
		exit(1);
	}
	return code;
}

But I doubt you actually *need* to use it as you suggested, because you
will probably rather want something like this:

switch (mybrlapi_readkey()) {
	case KEY_LEFT: foo; break;
	case KEY_RIGHT: foo; break;
}

which can be equally be written as:

brlapi_readkey(&code);
switch (code) {
	case KEY_LEFT: foo; break;
	case KEY_RIGHT: foo; break;
}

Samuel


More information about the BRLTTY mailing list