digitalmars.D.dwt - StyledText not accept Multi-bytes characters
- yidabu (40/40) Aug 18 2008 program crashed when StyledText.text encounter multi-bytes characters, e...
- Frank Benoit (7/48) Aug 18 2008 Yes, there is indeed trouble with it. StyledText uses
- John Reimer (9/60) Aug 18 2008 So what does this mean? Can't the utf8 text just be upconverted to utf1...
- Frank Benoit (4/15) Aug 19 2008 Both is needed, the utf8 and utf16.
- Frank Benoit (3/44) Aug 21 2008 I did some changes to TextLayout.
- yidabu (13/58) Aug 21 2008 dwtx.lib building error:
- Frank Benoit (2/55) Aug 21 2008 Should be fixed now.
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 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(); } -- yidabu <yidabu.spam gmail.com> http://www.dsource.org/projects/dwin D 语言-中文(D Chinese): http://www.d-programming-language-china.org/ http://bbs.d-programming-language-china.org/ http://dwin.d-programming-language-china.org/ http://scite4d.d-programming-language-china.org/
Aug 18 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 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 :/
Aug 18 2008
Frank Benoit wrote:yidabu schrieb:So what does this mean? Can't the utf8 text just be upconverted to utf16 using something like tango.text.convert.Utf.toString16 before the system function is called? I'd be interested to see the problem fully described so that I understand what to look out for while porting code. Is the information somewhere on our site? I recall you mentioning the issue in IRC recently. Thanks. -JJRprogram 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 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 :/
Aug 18 2008
John Reimer schrieb:So what does this mean? Can't the utf8 text just be upconverted to utf16 using something like tango.text.convert.Utf.toString16 before the system function is called? I'd be interested to see the problem fully described so that I understand what to look out for while porting code. Is the information somewhere on our site? I recall you mentioning the issue in IRC recently. Thanks. -JJRBoth is needed, the utf8 and utf16. I think the best is to have both versions in parallel and also maintain the indices for both.
Aug 19 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 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(); }I did some changes to TextLayout. Your example works now. More testing welcome.
Aug 21 2008
On Thu, 21 Aug 2008 09:59:31 +0200 Frank Benoit <keinfarbton googlemail.com> wrote:yidabu schrieb:dwtx.lib building error: dwt\ole\win32\OleControlSite.d(621): Error: e2ir: cannot cast from __GUID** to _ _GUID -- yidabu <yidabu.spam gmail.com> http://www.dsource.org/projects/dwin D 语言-中文(D Chinese): http://www.d-programming-language-china.org/ http://bbs.d-programming-language-china.org/ http://dwin.d-programming-language-china.org/ http://scite4d.d-programming-language-china.org/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 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(); }I did some changes to TextLayout. Your example works now. More testing welcome.
Aug 21 2008
yidabu schrieb:On Thu, 21 Aug 2008 09:59:31 +0200 Frank Benoit <keinfarbton googlemail.com> wrote:Should be fixed now.yidabu schrieb:dwtx.lib building error: dwt\ole\win32\OleControlSite.d(621): Error: e2ir: cannot cast from __GUID** to _ _GUIDprogram 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 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(); }I did some changes to TextLayout. Your example works now. More testing welcome.
Aug 21 2008