[pcre-dev] [Bug 1049] Add support for UTF-16

Góra strony
Delete this message
Autor: Gertjan Halkes
Data:  
Dla: pcre-dev
Stare tematy: [pcre-dev] [Bug 1049] New: Add support for UTF-16
Temat: [pcre-dev] [Bug 1049] Add support for UTF-16
------- You are receiving this mail because: -------
You are on the CC list for the bug.

http://bugs.exim.org/show_bug.cgi?id=1049

Gertjan Halkes <eximbugz@???> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |eximbugz@???





--- Comment #20 from Gertjan Halkes <eximbugz@???> 2011-11-15 09:34:38 ---
(In reply to comment #15)
> > By the way, does anyone know a clever way of compile time endianness check?
>
> Don't you just set up an int and then cast a pointer to it as char * and
> then look at the bytes?
>

I've found that using pointer casting can cause some ugly compiler warnings
(mind you, I was dealing with doubles at the time). A cleaner way is using a
union:

static const union { int i; char c; } order = { 1 }; /* initialisation assigns
first union member */

You can then simply check:

if (order.c == 1) {
/* little endian */
} else {
/* big endian */
}

Both gcc and llvm/clang recognize this correctly and optimize out the unused
case.


--
Configure bugmail: http://bugs.exim.org/userprefs.cgi?tab=email