Results 1 to 2 of 2

Thread: Conversion of Unicode to Japanese

  1. #1
    Join Date
    May 2007
    Posts
    110
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Conversion of Unicode to Japanese

    Hi

    I have files with fileName in Japanese Language..My Application is generating Dir View from Hard Disk....All english file name is showing in English..But I want to show Japanese fileName in Japanese Language....

    Some of the Code is as follows:

    QChar CFileName[512];
    QString bFileName = tr("");
    memset(CFileName,0x00,sizeof(CFileName));
    memcpy((void*)CFileName,(const void *)&bNodeBuff[wRecordOffset+ sizeof(unsigned short)+ sizeof(unsigned long)+sizeof(unsigned short)],wNameLength*2);
    if(!ProgramRunningOnPowerPc)
    {
    GetUnicodeStringForPowerPC((unsigned char *)CFileName, wNameLength*2);
    }

    QString qtemp(CFileName,wNameLength);
    //bFileName = qtemp;

    //QTextCodec *codec = QTextCodec::codecForName("Shift-JIS");
    //QByteArray encodedString = codec->fromUnicode(CFileName);
    //bFileName = encodedString.data();

    QByteArray byteRead = qtemp.toAscii();

    QTextCodec *codec = QTextCodec::codecForName("Shift-JIS");

    QTextStream in(&byteRead);
    in.setAutoDetectUnicode(false);
    in.setCodec(codec);
    QString decodedStr = in.readAll();

    bFileName = decodedStr;

    But japanese filename come as ??????.txt, ?????.jpeg etc...
    What is wrong here?

    How to get actual japanese file name in Dir View....

    If anybody know help please

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Conversion of Unicode to Japanese

    Quote Originally Posted by santosh.kumar View Post
    memset(CFileName,0x00,sizeof(CFileName));
    memcpy((void*)CFileName,(const void *)&bNodeBuff[wRecordOffset+ sizeof(unsigned short)+ sizeof(unsigned long)+sizeof(unsigned short)],wNameLength*2);
    if(!ProgramRunningOnPowerPc)
    {
    GetUnicodeStringForPowerPC((unsigned char *)CFileName, wNameLength*2);
    }
    You are asking for trouble here. Never use memset to initialize class instances. Also you can't simply cast QChar[] to usigned short*.

    What encoding does bNodeBuff use for the file name?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.