# HG changeset patch # User Frank Benoit # Date 1204478384 -3600 # Node ID 2708124a8f6c9d2e5032f0fefbc5ff7466f81ecf # Parent 6b45e37660492f5f3f2247105608fb5375ff2cfc Fix: utf8 awareness diff -r 6b45e3766049 -r 2708124a8f6c dwt/widgets/Link.d --- a/dwt/widgets/Link.d Sun Mar 02 18:14:28 2008 +0100 +++ b/dwt/widgets/Link.d Sun Mar 02 18:19:44 2008 +0100 @@ -44,6 +44,7 @@ import tango.text.Unicode; alias tango.text.Text.Text!(char) Text8; + /** * Instances of this class represent a selectable * user interface object that displays a text with @@ -530,10 +531,13 @@ mnemonics = new int[] ( length_ / 4 + 1 ); Text8 result = new Text8 (); char [] buffer = string.dup; + int index = 0, state = 0, linkIndex = 0; int start = 0, tagStart = 0, linkStart = 0, endtagStart = 0, refStart = 0; while (index < length_) { - char c = tango.text.Unicode.toLower (buffer [index .. index+1])[0]; + int increment; + dchar c = CharacterFirstToLower (buffer [index .. $ ], increment ); + switch (state) { case 0: if (c is '<') { @@ -629,7 +633,7 @@ state = 0; break; } - index++; + index+=increment; } if (start < length_) { int tmp = parseMnemonics (buffer, start, tagStart, result); @@ -656,7 +660,8 @@ int parseMnemonics (char[] buffer, int start, int end, Text8 result) { int mnemonic = -1, index = start; while (index < end) { - if (buffer [index] is '&') { + int incr = 1; + if ( buffer[index] is '&') { if (index + 1 < end && buffer [index + 1] is '&') { result.append (buffer [index]); index++; @@ -664,9 +669,9 @@ mnemonic = result.length(); } } else { - result.append (buffer [index]); + result.append ( firstCodePointStr( buffer [index .. $ ], incr )); } - index++; + index+=incr; } return mnemonic; } @@ -711,7 +716,7 @@ public void setText (char[] string) { checkWidget (); if (string is null) error (DWT.ERROR_NULL_ARGUMENT); - if (string ==/*eq*/ text) return; + if (string.equals(text)) return; text = string; layout.setText (parse (string)); focusIndex = offsets.length > 0 ? 0 : -1;