Game Development Community

Unicode conversion bug?

by Jari · in Torque Game Engine · 04/29/2006 (11:05 am) · 1 replies

Hi, I think there's a bug in the unicode conversion functions.
This is very difficult to demonstrade because these forums don't allow scandinavian characters and the bug is related to them and I don't know how you american folks can test this but here goes anyway:

Put this in your engine and put some wierd string to testString, compile and call tu() then see the windows system console not the torque console for interesting results...

#include <stdio.h> // use the std console directly

char * testString = ""; // but the scandinavian characters here!

ConsoleFunction(tu,void,1,1,"tests unicode") 
{
   UTF16 test16[2048];
			UTF8 test8[2048];

			printf("testing unicode\n");



			printf("%s   ---   %d\n",testString,dStrlen(testString));

			// first convert the testString to unicode
   convertUTF8toUTF16((UTF8 *)testString, test16, sizeof(test16));
			// then convert it back to ascii
   convertUTF16toUTF8(test16, test8, sizeof(test8));

			printf("%s   ---   %d\n",test8,dStrlen(test8));
}

calling tu() outputs:

www.upimages.net/upload/d2a62af6.png
I put six scandinavian chars in testString and that's what it gave.

This is a problem because I was trying to execute and exe from my desktop but since path to the desktop has scandinavian chars it doesnt work.

#1
05/01/2006 (6:28 am)
The problem seems to be that the characters I'm trying to convert are not in range of 0 - 255 in the testString and while this works when using plain ascii functions problems begin with unicode. So there probably isn't anything wrong with TGE.