×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Jul 2004
    Posts
    44

    grabbing hex value of a TChar?

    how to grab hex value of a TChar character?

    TBuf<3> temp;
    temp.Format(KHex, myText[0]);


    where myText is a TBuf<255>.

    But it doesn't work if the input character is Ü or other special character.

    i need to do this so i can convert input string to hex to post through HTTP.

    please help. thanks.

  2. #2
    Regular Contributor
    Join Date
    Apr 2005
    Posts
    89
    Convert it to UTF-8 first, then resulting sequence of bytes to hex. That's what google does (examine the URL):
    http://www.google.com/search?hl=en&l...9C&btnG=Search
    http://www.google.com/search?hl=en&l...AD&btnG=Search
    But actually you should find out first what does your server expect.

  3. #3
    Registered User
    Join Date
    Jul 2004
    Posts
    44
    hello,

    how does one convert, say, the character Ü into UTF-8 in symbian?

    thanks.

  4. #4
    Regular Contributor
    Join Date
    Mar 2003
    Location
    UK
    Posts
    159
    Originally posted by _nomad_
    hello,

    how does one convert, say, the character Ü into UTF-8 in symbian?

    thanks.
    You could try searching for "utf convert" in the SDK help for starters...

  5. #5
    Registered User
    Join Date
    Jul 2004
    Posts
    44
    hi,

    I have this now:

    Code:
          // Grab hex value of non-alpha numeric characters
          TInt mySize = myBufC->Size() + 3;
          myBufC = myBufC->ReAllocL(mySize);
    
          TBuf16<1> uniCode;
          uniCode.Copy(_L(""));
          uniCode.Append(myText[ctr]);
    
          HBufC8* asciiCode = UtilitiesWrapper::UnicodeToAsciiLC(uniCode);
          TBuf<1> asciiFinal;
          asciiFinal.Copy(asciiCode->Des());
    
          TBuf<2> temp;
          temp.Format(KHex, asciiFinal[0]);
    
          CEikonEnv::Static()->InfoWinL(_L("temp:"), temp);
    
          myBufC->Des().Append(_L("%"));
          myBufC->Des().Append(temp);
          CEikonEnv::Static()->InfoWinL(_L("myBufC:"), myBufC->Des());

    where UnicodeToAsciiLC() is a function i got at: http://forum.newlc.com/index.php?topic=685.0 which works since the first InfoWinL displays the correct hex value, but after .Append() the hex value, the second InfoWinL shows that nothing was appended.

    what's going on here?.

  6. #6
    Registered User
    Join Date
    Jul 2004
    Posts
    44
    hi,

    i have this:

    Code:
    TBuf8<2> asciiFinal;
    _LIT(KHex, "%%%02x");
          CnvUtfConverter::ConvertFromUnicodeToUtf8(asciiFinal, uniCode);
    
    temp.Format(KHex, asciiFinal);
    
    CEikonEnv::Static()->InfoWinL(_L("temp:"), temp);
    where variable uniCode that i pass into ConvertFromUnicodeToUtf8() is:

    Code:
          TBuf16<1> uniCode;
          uniCode.Append(myText[ctr]);

    the myText array just stores the character input user did...it is a TBuf.

    but i always get %30 as result when inputing special characters like Ü or Ö, etc ...which is obviously wrong...

    please help.

Posting Permissions

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