changeset 181:2708124a8f6c

Fix: utf8 awareness
author Frank Benoit <benoit@tionex.de>
date Sun, 02 Mar 2008 18:19:44 +0100
parents 6b45e3766049
children 721afe91f448
files dwt/widgets/Link.d
diffstat 1 files changed, 11 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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;