×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Regular Contributor
    Join Date
    Jun 2009
    Posts
    92

    getting utf8 chars via http

    Hi,

    I developed a small application which connects to a web page (using RHTTPSession and RHTTPTranscation) and receives a few words of data.
    The site returns the data in utf8 encoding (server side is ASP.Net).
    On the symbian side, I'm getting gibberish letters instead of the foreign characters (English characters are ok).

    What am I doing wrong?
    Should I specify somewhere in the transaction that I'm receiving utf8 data?
    Should I "escape" the utf8 string on the server before sending it to the phone?

    Regarding the server side, I set the headers to utf8 encoding and charset.
    I tried using ConvertToUnicodeFromUtf8 on the received string but I get the same gibberish characters encoded into escaped form.

    Thanks.

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,750

    Re: getting utf8 chars via http

    Since you probably already do a 8-bit -> 16-bit descriptor conversion, that is the step where you can decode UTF8: use CnvUtfConverter::ConvertToUnicodeFromUtf8L.

  3. #3
    Regular Contributor
    Join Date
    Jun 2009
    Posts
    92

    Re: getting utf8 chars via http

    Quote Originally Posted by wizard_hu_ View Post
    Since you probably already do a 8-bit -> 16-bit descriptor conversion, that is the step where you can decode UTF8: use CnvUtfConverter::ConvertToUnicodeFromUtf8L.
    What do you mean 8bit -> 16bit descriptor conversion?
    The received http body is TDesc8.

    I already tried using ConvertToUnicodeFromUtf8.

    Thanks.

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,750

    Re: getting utf8 chars via http

    I assumed that you were displaying that text somehow. Everything what you can display in Symbian C++ is necessarily a 16-bit descriptor, while the content you get from the network comes in 8-bit descriptors.

  5. #5
    Regular Contributor
    Join Date
    Jun 2009
    Posts
    92

    Re: getting utf8 chars via http

    Quote Originally Posted by wizard_hu_ View Post
    I assumed that you were displaying that text somehow. Everything what you can display in Symbian C++ is necessarily a 16-bit descriptor, while the content you get from the network comes in 8-bit descriptors.
    No, I do not display it.

    I just realized that when I'm using ConvertToUnicode, I get the right data only in hex form (\x05D0 for example).

    How do I convert it to characters?

    thanks.

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,750

    Re: getting utf8 chars via http

    Quote Originally Posted by rmanor View Post
    No, I do not display it.
    Then how do you know if it is rubbish or not? Something being a correct Unicode character/string, and something displayed by the debugger of Carbide (is this what happens? (*) ) are two different things.
    I just realized that when I'm using ConvertToUnicode, I get the right data only in hex form (\x05D0 for example).
    (*) Yes it is.
    How do I convert it to characters?
    Those are characters already. Carbide displays them in this way, period.

  7. #7
    Regular Contributor
    Join Date
    Jun 2009
    Posts
    92

    Re: getting utf8 chars via http

    Quote Originally Posted by wizard_hu_ View Post
    Then how do you know if it is rubbish or not? Something being a correct Unicode character/string, and something displayed by the debugger of Carbide (is this what happens? (*) ) are two different things.(*) Yes it is.Those are characters already. Carbide displays them in this way, period.
    Thanks! I guess that was a stupid newbie question on my part.

    Now I have another problem.
    My goal was to give this data to the CParser for xml parsing.
    I just figured out that CParser should accept the encoded data (utf8).. stupid me.
    but when I give it to the parser (with the right utf8 xml encoding header), the data isn't being decoded and I get rubbish again.

    How do I tell the parser to decode it? or should I just decode it myself after extracting the data from the xml?

    Thanks again.

  8. #8
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,750

    Re: getting utf8 chars via http

    Yes, the order should be "data from the net"->CParser->OnContentL->CnvUtfConverter::ConvertToUnicodeFromUtf8L. So parse the 'raw' data.

  9. #9
    Regular Contributor
    Join Date
    Jun 2009
    Posts
    92

    Re: getting utf8 chars via http

    Quote Originally Posted by wizard_hu_ View Post
    Yes, the order should be "data from the net"->CParser->OnContentL->CnvUtfConverter::ConvertToUnicodeFromUtf8L. So parse the 'raw' data.
    I understand.
    Thanks a lot!

Similar Threads

  1. Replies: 2
    Last Post: 2006-10-06, 17:24
  2. HTTP Client - Synchronous HTTP POST Calls?
    By symbian_ravi in forum Symbian Networking & Messaging (Closed)
    Replies: 5
    Last Post: 2006-04-16, 11:51
  3. UTF8 Http Response
    By christine_eff in forum Mobile Java General
    Replies: 0
    Last Post: 2005-01-31, 02:13

Posting Permissions

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