×

Discussion Board

Results 1 to 13 of 13
  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    62

    Problem in Arabic writing

    I use Qt 4.6.2 in fedora "linux", I create array with static values contains Arabic strings.

    but when I tried to retrieve any value from my array the string returns with value

    = NULL.

    I use "char*" to save my values.

    Is there problem in the encoding?

    can any one help me?

  2. #2
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Problem in Arabic writing

    Have you tried regular Roman/ASCII characters in the same scenario?

  3. #3
    Super Contributor
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    2,326

    Lightbulb Re: Problem in Arabic writing

    Quote Originally Posted by NMMA View Post
    I use Qt 4.6.2 in fedora "linux", I create array with static values contains Arabic strings.

    but when I tried to retrieve any value from my array the string returns with value

    = NULL.

    I use "char*" to save my values.

    Is there problem in the encoding?

    can any one help me?
    There is only a small set of characters that you can use in a GET request. Other than A-Z, a-z, 0-9 and a few other characters, anything else needs to be URL encoded ("%xx", where "xx" is the hex code for the byte).

    Since a "%xx" code can represent only one byte, it cannot be used to encode Unicode characters. You must convert the Unicode characters into bytes first.

    The best way to encode Unicode as a sequence of bytes is to encode as UTF-8.

    UTF-8 will encode Arabic characters as two bytes each.



    For more information visit below disscusion :
    http://discussion.forum.nokia.com/fo...d.php?t=168291
    http://discussion.forum.nokia.com/fo...ad.php?t=59463
    http://discussion.forum.nokia.com/fo...d.php?t=165996


    best regards,

  4. #4
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Problem in Arabic writing

    I think your problem might be related to an editor you use
    Code:
    #include <QtGui>
    
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
        const char *str = "رسالة اختبار";
        QString string = QString::fromUtf8 (str);
        qDebug() << QString("Unicode length %1 ASCII length %2").arg(string.length()).arg(strlen(str));
        for (int i = 0; str[i]; i++)
            qDebug() << QString("[%1]").arg(str[i]);
        for (int i = 0; i < string.length(); i++)
            qDebug() << QString("[%1]").arg(string.at(i));
    }

  5. #5
    Registered User
    Join Date
    Apr 2010
    Posts
    62

    Re: Problem in Arabic writing

    Thanx all for ur reply,

    I want to know how to convert my text from utf-8 to ANSI manually without using Qstring?

  6. #6
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Problem in Arabic writing

    Quote Originally Posted by NMMA View Post
    Thanx all for ur reply,

    I want to know how to convert my text from utf-8 to ANSI manually without using Qstring?
    There is no way to convert UTF-8 to Windows-1252 as the former is a superset of the latter.
    Last edited by divanov; 2010-05-30 at 09:41. Reason: typo

  7. #7
    Registered User
    Join Date
    Apr 2010
    Posts
    62

    Re: Problem in Arabic writing

    I cannot do function that do mapping between UTF-8 representation and ANSI?

  8. #8
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Problem in Arabic writing

    Quote Originally Posted by NMMA View Post
    I cannot do function that do mapping between UTF-8 representation and ANSI?
    Well, how do you define mapping? If it's about conversion then you can check how iconv deal with the similar task
    http://www.gnu.org/software/libiconv/

  9. #9
    Registered User
    Join Date
    Apr 2010
    Posts
    62

    Re: Problem in Arabic writing

    Thanx for ur quick reply

    but I have Question..

    If I use UTF-8...I need to store my output in wchar? or I can continue to use my char*?

  10. #10
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Problem in Arabic writing

    Quote Originally Posted by NMMA View Post
    If I use UTF-8...I need to store my output in wchar? or I can continue to use my char*?
    To answer the Question I will need to know how are you planning to use the output.

  11. #11
    Registered User
    Join Date
    Apr 2010
    Posts
    62

    Re: Problem in Arabic writing

    I want to store arabic character in "char*" and use "switch" to make

    some comparison like that:

    Code :

    char* one="صفر"
    int len=strlen(one);
    int i = 0;
    for(i = 0;i<len;i++)
    {
    //
    //
    switch(one[i])
    {
    case 'َ':
    one[i]= 'a';
    break;
    case 'ِ':
    one[i]='i';
    break;
    case 'ُ':
    one[i]='u';
    break;
    case 'ّ':
    one[i]='+';
    break;
    case 'ْ':
    one[i]='o';
    break;
    case 'ً':
    one[i]='&';
    break;
    case 'ٌ':
    one[i]='$';
    break;
    case 'ٍ':
    one[i]='%';
    break;
    case 'ء':
    one[i]='?';
    break;
    case 'ا':
    one[i]='A';
    break;
    case 'إ':
    one[i]='I';
    break;
    case 'ؤ':
    one[i]='U';
    break;
    case 'ئ':
    one[i]='Y';
    break;
    case 'أ':
    one[i]='P';
    break;
    case 'ب':
    one[i]='b';
    break;
    case 'ت':
    one[i]='t';
    break;
    case 'ة':
    one[i]='e';
    break;
    case 'ث':
    one[i]='c';
    break;
    case 'ج':
    one[i]='j';
    break;
    case 'ح':
    one[i]='H';
    break;
    case 'خ':
    one[i]='K';
    break;
    case 'د':
    one[i]='d';
    break;
    case 'ذ':
    one[i]='>';
    break;
    case 'ر':
    one[i]='r';
    break;
    case 'ز':
    one[i]='z';
    break;
    case 'س':
    one[i]='C';
    break;
    case 'ش':
    one[i]='s';
    break;
    case 'ص':
    one[i]='S';
    break;
    case 'ض':
    one[i]='D';
    break;
    case 'ط':
    one[i]='T';
    break;
    case 'ظ':
    one[i]='Z';
    break;
    case 'ع':
    one[i]='E';
    break;
    case 'غ':
    one[i]='g';
    break;
    case 'ف':
    one[i]='f';
    break;
    case 'ق':
    one[i]='q';
    break;
    case 'ك':
    one[i]='k';
    break;
    case 'ل':
    one[i]='L';
    break;
    case 'م':
    one[i]='m';
    break;
    case 'ن':
    one[i]='n';
    break;
    case 'ه':
    one[i]='h';
    break;
    case 'و':
    one[i]='w';
    break;
    case 'ي':
    one[i]='y';
    break;
    case 'آ':
    one[i]='@';
    break;
    case 'ى':
    one[i]='V';
    break;
    default:
    break;
    }

    }
    First, when I do that.size of len return with value=6 although I set str with 3 letters
    I need to use wchar? how I can deal with this situation ?

  12. #12
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Problem in Arabic writing

    Quote Originally Posted by NMMA View Post
    I want to store arabic character in "char*" and use "switch" to make
    some comparison like that:

    First, when I do that.size of len return with value=6 although I set str with 3 letters
    I need to use wchar? how I can deal with this situation ?
    Arabic letters as being non-Latin take 2 bytes for storing in UTF-8. However, some other alphabets can take even more. In order to produce portable code, you should switch to using QString instead of char* and QChar instead of char. You won't be able to use switch operator for comparing Unicode characters as they are of non elementary type, but rather a strings.
    Here is a small example:
    http://doc.qt.nokia.com/4.6/qstring.html#operator-5b-5d

  13. #13
    Registered User
    Join Date
    Apr 2010
    Posts
    62

    Re: Problem in Arabic writing

    Quote Originally Posted by divanov View Post
    Arabic letters as being non-Latin take 2 bytes for storing in UTF-8. However, some other alphabets can take even more. In order to produce portable code, you should switch to using QString instead of char* and QChar instead of char. You won't be able to use switch operator for comparing Unicode characters as they are of non elementary type, but rather a strings.
    Here is a small example:
    http://doc.qt.nokia.com/4.6/qstring.html#operator-5b-5d
    Thanks too much for your reply
    my problem finally solved

Similar Threads

  1. Modules required :)
    By neil.young in forum Symbian
    Replies: 20
    Last Post: 2009-06-07, 11:35
  2. problem in sending arabic text in URL
    By honest_success in forum Mobile Java General
    Replies: 22
    Last Post: 2009-05-23, 13:37
  3. Problem writing to C:/Data
    By overtime66 in forum Mobile Java General
    Replies: 3
    Last Post: 2008-12-08, 12:08
  4. Problem while writing on perticular port using socket
    By Kranti in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2008-11-04, 10:45
  5. Problem with writing buffer to file
    By ArneH in forum Symbian
    Replies: 5
    Last Post: 2004-08-31, 08:48

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×