Game Development Community

Unicode Bug in GuiTextListCtrl

by Ian Omroth Hardingham · in Torque Game Engine · 11/22/2007 (8:00 am) · 1 replies

Hey guys.

GuiTextListCtrl::renderCell does not function properly with UTF8s. Paul Dana and I cooked up a quick hack for it. Basically, change:

if(nextCol)
            slen = nextCol - text;
         else
            slen = dStrlen(text);

at line 280-ish

to


if (nextCol)
         {
            *nextCol = 0;

            U32 numCodePoints, bufferLen;
            bufferLen = dStrlen(text)+1;                   // Need the +1 to hold the NULL
            UTF16  *buffer16 = new UTF16[bufferLen];     // need len * 2 bytes == len * sizeof(UTF16)
            numCodePoints = convertUTF8toUTF16(text, buffer16, bufferLen);
            

            slen = numCodePoints;


            *nextCol = '\t';

         }
         else
         {
            
            slen = dStrlen(text);
         }

and also put

#include "core/unicode.h"

at the top.

Ian

#1
11/22/2007 (8:01 am)
Oh yeah, you also have to de-const some stuff, specifically

char *text = mList[cell.y].text;

and

char *nextCol = dStrchr(text, '\t');


which were both const previously.