MacArthur, Ian (SELEX GALILEO, UK) wrote:
> Actually, I'm not sure MK's code will really fly as-is on win32 hosts...
> He uses wchar_t as his passed parameter type, but it is apparent from
> the way that he uses it that he assumes this is at least a 32-bit type.
>
> E.g. at or near line 202 / 203 of wcwidth.c he compares it to 0x2fffd
> and other values larger than 16-bits...
>
> However, on win32 systems, wchar_t is only a 16-bit type, and this part
> of the code will not work.
> I don't have a Mac or Unix box to hand, but I assume most have a 32-bit
> wchar_t (e.g. I assume they are using some UCS-4 (or UTF-32) type
> encoding...)
Yep, you got it!
I wrote a small test program with MK's wcwidth.c contents + this:
/* begin test */
#include <stdio.h>
int main (int argc, char **argv) {
printf ("sizeof wchar_t = %d\n",sizeof(wchar_t));
return 0;
}
/* end of test */
On Linux: no compiler warnings, output as expected:
sizeof wchar_t = 4
On Windows (compile + run):
$ gcc -o wchar wchar.c && ./wchar
wchar.c: In function `mk_wcwidth':
wchar.c:202: warning: comparison is always false due to limited range of data
type
wchar.c:202: warning: comparison is always true due to limited range of data
type
wchar.c:203: warning: comparison is always false due to limited range of data
type
wchar.c:203: warning: comparison is always true due to limited range of data
type
sizeof wchar_t = 2
--- end ---
Also as expected :-(
> Problems with mk_wcwidth aside, here's a possible implementation then:
--- snip ---
Didn't check this yet. Maybe later.
Albrecht
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev