Show us a piece of actual code
Show us a piece of actual code
a life without programming is like an empty bottle![]()
FILE *fp = NULL;
HEADER_FILE Header;
HEADER_FILE *SearchHeaderStart=NULL,*SearchHeader=NULL;
memset(&Header,0x00,sizeof(HEADER_FILE));
QString CurrentPath=QDir::currentDirPath ()+"/HeaderFile.cfg";
fp = fopen((const char *)CurrentPath,"rb");
if(fp!= NULL)
{
while(1)
{
if(feof(fp))
break;
if(!SearchHeader)
SearchHeaderStart=SearchHeader=(HEADER_FILE*)callo c(1,sizeof(HEADER_FILE));
else
{
SearchHeader->next=(HEADER_FILE*)calloc(1,sizeof(HEADER_FILE) );
SearchHeader=SearchHeader->next;
}
fread(&Header,sizeof(HEADER_FILE),1,fp);
memset( SearchHeader,0x00,sizeof(HEADER_FILE));
QChar SoftwareName[260*2];
memset(SoftwareName,0x00,260*2);
memcpy((void*)SoftwareName,(const void*)&Header.bSoftwareName,(260*2));
QString Name(SoftwareName,260);
QMessageBox::information(0,"Software Name",Name);
Following is a Structure to read data from a file Header.cfg in which data is written According to following structure and we have to read this structures from this file and make a link list but when i am displaying the Header.bSoftwareName then get the first character of softwareName right but how can i get the whole name because the name is written in unicode in .cfg file.
typedef struct tagAppendHdrFile
{
tagAppendHdrFile *next;
char bSoftwareName[260*2];
char bFileExt[260*2];
}HEADER_FILE;
Best Regards
First of all use CODE tags for showing your code..also why you dont use QString instead of char *, QFile istead of FILE, and something like QPtrList istead of using pointer on next item in your struct![]()
a life without programming is like an empty bottle![]()
Hi
Because i am using same type of code on windows plateform. Please help me how i can show the unicode name.
Thanks and regards
If you were using Qt classes, you wouldn't have this problem.
QChar is a class --- it isn't safe to initialize it using memcpy. Not mentioning that &Header.bSoftwareName is char **.Qt Code:
memset(SoftwareName,0x00,260*2); memcpy((void*)SoftwareName,(const void*)&Header.bSoftwareName,(260*2));To copy to clipboard, switch view to plain text mode
This might work:Qt Code:
QString name; if( codec != 0 ) { name = codec->toUnicode( Header.bSoftwareName, 2*260 ); }To copy to clipboard, switch view to plain text mode
Hi all,
I want to read unicode names written in a file. Which QT classes i have to use for handling unicode string and i have to display this string on QMessageBox or QlistView. please help me by giving code snippet.
Best Regards
It really helps if you try to read the documentation before asking a question.Originally Posted by darpan
Look at QFile, QTextCodec and QTextStream.
Save yourself some pain. Learn C++ before learning Qt.
Bookmarks