On 23/11/2010 23:26, Duncan Gibson wrote:
>
> Would it not be possible to embed the fl_utf8decode() into a method
> in a "character input" class. The base class would handle ASCII and
> valid UTF-8 sequences. One derived class could handle ISO-8859-1
> conversion, and another could be extended further to handle CP1252.
> Users would be free to provide their own derived classes as needed.
> The Fl class could have a "character input" class pointer member
> so that the user could customise character conversion at the start
> of execution.
I have seen that there is some ucs (int) api added fltk-1.3.
To keep things simple, one could add cheap (inline?) method to text buffer, like
Fl_Text_Buffer::append(int ucs);
User then could fill buffer by external means with own conversion
(eg using table or function for conversion from cp1252 to ucs):
static int cp1252_to_ucs_table[] = {0, 1, ...};
FILE * f = fl_fopen("/some/file.CP1252", "rb");
if(f){
int c;
while(EOF!= (c=getc(f)))
text_buffer->append(cp1252_to_ucs_table[c]);
fclose(f);
}else
printf("Oh, crap!);
R.
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev