PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

How to read TCHAR text from files

Hi! It is not really a bug, but can you please tell me, what type of variable should I use with textFile.read(&buffer;, 1000) for &buffer.; When type is BYTE, by default, it reads well from non-unicode text documents, but I can not figure out, how to output loaded text with pBackBuffer->drawFormattedText, because it requers TCHAR type as 5th parametr. And if I set &buffer; variable as TCHAR type, or any other (not BYTE), it is not working with unicode, and none-unicode text documents, I mean it reads just some single characters like '[]' in to the &buffer; variable and thats is all. Maybe there is some way to convert from byte to tchar? I have read many manuals for this 4 days and just can't figure it out.
Currently, you can't do that. But you are right, that's something you'll need, and it will be interesting to have it implemented in GledSave. That's why we are now implementing a solution.

Meanwhile, you could use this ugly workaround:

Code:

TCHAR text[15];
BYTE buffer[15];
root.read(buffer, 15);
for(int i=0; i<15; i++){
text[i] = (TCHAR)buffer[i];
}
text[14]=0;


ASAP we will bring you a solution.

Thank you for your Feedback!

Matias
Hi! It is not ugly workaround and works perfect for me =) Afcourse, I don't really know how fast will it work for huge text files (500kb or more), but for now it is ok for futher testings - thanks for answering very fast. At last now I know how to convert between different types :)
Hi Ryumaster,
I'm happy to tell you that the new GledPlay release (build 195) implements a nicer solution for this problem.

Now, the File class has a readLine method, which loads text from a plain ascii file, to a TCHAR* string.

http://www.gledplay.com/doc/GledSave/File.html#readLine

Regards,
Sergio.
Great! You are really doing a very great job, I'm happy that I'm using GledPlay :)