StyledText not accept Multi-bytes characters

Frank Benoit keinfarbton at googlemail.com
Mon Aug 18 02:43:52 PDT 2008


yidabu schrieb:
> program crashed when StyledText.text encounter multi-bytes characters, e.g. Chinese.
> 
> code below causes EXCEPTION_ACCESS_VIOLATION :
> Unhandled Exception: EXCEPTION_ACCESS_VIOLATION(0xc0000005) at ntdll.dll (0x7c90316c) thread(1260)
> ->us
> #0 ?? () from ntdll.dll
> 
> Code:
> 
> import dwt.DWT;
> import dwt.custom.StyledText;
> import dwt.custom.StyleRange;
> import dwt.layout.FillLayout;
> import dwt.widgets.Display;
> import dwt.widgets.Shell;
> import dwt.widgets.Listener;
> import dwt.widgets.Event;
> import dwt.graphics.Color;
> import dwt.graphics.Point;
> 
> import dwt.dwthelper.utils;
> 
> void main() {
>     static String SEARCH_STRING = "box";
>     Display display = new Display();
>     Color RED = display.getSystemColor(DWT.COLOR_RED);
>     Shell shell = new Shell(display);
>     shell.setBounds(10,10,250,250);
>     StyledText text = new StyledText(shell, DWT.NONE);
>     text.setBounds(10,10,200,200);
>     text.setText("StyledText not accept Chinese 中国? ");
>     shell.open();
>     while (!shell.isDisposed()) {
>         if (!display.readAndDispatch()) display.sleep();
>     }
>     display.dispose();
> }
> 
> 
> 
> 


Yes, there is indeed trouble with it. StyledText uses 
dwt.graphics.TextLayout which implements all this and is the troublemaker.
Especially on windows the ported code is not working correctly.
This is because of dwt uses utf8 storage but the windows api uses utf16. 
This make the calculation of indices very hard.
It is on my TODO list since a while now :/











More information about the Digitalmars-d-dwt mailing list