[sane-devel] Character encoding used for sane_strstatus() strings

John Scott jscott at posteo.net
Mon Jul 18 15:47:49 BST 2022


On Mon, 2022-07-18 at 13:19 +0300, Povilas Kanapickas wrote:
> By the way, does the current assumption actually break in practice, that
> is, are there compilers for which ASCII text will not encode to a subset
> of ISO-8859-1?
I assume you mean "Are there compilers for which narrow/multibyte string
literals will not encode to a subset of ISO-8859-1?" In that case, I
haven't researched the matter and don't know of a system for which this
is a problem off the top of my head.

Note that if we're unwilling to bump compiler requirements to C11, there
are still a couple options. GCC has the -fexec-charset option to specify
what encoding "ordinary" string literals should be in; we can set this
to ISO-8859-1 when building SANE, but this won't be portable to
compilers without this option.

We could also define a macro that's compatible with older compilers like
this:
#if __STDC_VERSION__ >= 201112L
#define SANE_STRING(X) u8##X
#else
#define SANE_STRING(X) X
#endif

Lastly, iconv() is always an option.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: This is a digitally signed message part
URL: <http://alioth-lists.debian.net/pipermail/sane-devel/attachments/20220718/42442cbd/attachment.sig>


More information about the sane-devel mailing list