×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Regular Contributor
    Join Date
    Nov 2011
    Posts
    51

    Spliting the character in message

    I need to split the characters and need to get a output = 123.

    i am using below TLex to split the same, but not able to fetch the required output. Kindly need your suggest to get the required out put.

    _LIT(KNew, "::::12----A$$$$123::::23");

    TLex lex(KNew);
    TChar ch;

    TBuf8<50> token;

    while((ch = lex.Get()) != 0 )
    {
    while ((ch = lex.Peek()) != '::::')
    lex.Inc();

    token.Copy(lex.MarkedToken());

    /* Now we have the string as the token,
    * do something.. */

    lex.Inc();
    lex.Mark();
    }

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

    Re: Spliting the character in message

    I am not sure how '::::' compiles, but "TChar ch" can contain a single character, and single quotes are also meant to surround a single character.
    TLex::Peek is cute, but practically unusable. Consider parsing the string with descriptor methods, like Find and Mid, and use TLex as the last step only
    Code:
    _LIT(KNew, "::::12----A$$$$123::::23");
    _LIT(KMarker1,"$$$$");
    _LIT(KMarker2,"::::");
    TBuf<100> buf=KNew;
    
    TInt pos1=buf.Find(KMarker1);
    if(pos1!=KErrNotFound)
    {
        TInt pos2=buf.Mid(pos1+KMarker1.Length()).Find(KMarker2);
        if(pos2!=KErrNotFound)
        {
            TLex lex(buf.Mid(pos1+KMarker1.Length(),pos2);
            lex.Val(...)
        }
    }
    Of course it is also possible to do real stream-processing, and consume the input character by character, but that will require a complicated state machine since you will have to "remember" the previous characters you have seen.

  3. #3
    Regular Contributor
    Join Date
    Nov 2011
    Posts
    51

    Re: Spliting the character in message

    Quote Originally Posted by wizard_hu_ View Post
    I am not sure how '::::' compiles, but "TChar ch" can contain a single character, and single quotes are also meant to surround a single character.
    TLex::Peek is cute, but practically unusable. Consider parsing the string with descriptor methods, like Find and Mid, and use TLex as the last step only
    Code:
    _LIT(KNew, "::::12----A$$$$123::::23");
    _LIT(KMarker1,"$$$$");
    _LIT(KMarker2,"::::");
    TBuf<100> buf=KNew;
    
    TInt pos1=buf.Find(KMarker1);
    if(pos1!=KErrNotFound)
    {
        TInt pos2=buf.Mid(pos1+KMarker1.Length()).Find(KMarker2);
        if(pos2!=KErrNotFound)
        {
            TLex lex(buf.Mid(pos1+KMarker1.Length(),pos2);
            lex.Val(...)
        }
    }
    Of course it is also possible to do real stream-processing, and consume the input character by character, but that will require a complicated state machine since you will have to "remember" the previous characters you have seen.
    Thanks a lot, but out put is displaying as 123.000. and pls let me how to convert the output TDesC16.

  4. #4
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    3,956

    Re: Spliting the character in message

    Quote Originally Posted by lakshmishar View Post
    Thanks a lot, but out put is displaying as 123.000
    Seems that you have used : TInt Val(TReal64 &aVal)

    instead use : TInt Val(TInt&aVal)

  5. #5
    Regular Contributor
    Join Date
    Nov 2011
    Posts
    51

    Cool Re: Spliting the character in message

    THANKS A LOT FOR ENTIRE NOKIA DEVELOPER FORUM. TODAY I HAVE COMPLETED MY PROJECT.

    sorry to all for troubling lot. I was new for this symbian C++ but i learn lot while doing this project..

    Thanks again for entire team..

Similar Threads

  1. displaying japanese character or hindi character on phone
    By akhil0706 in forum Mobile Java General
    Replies: 4
    Last Post: 2010-08-04, 17:47
  2. Replies: 1
    Last Post: 2007-01-11, 16:50
  3. Guideline to delete character by character content of CEikRichTextEditor
    By bharat.kamble in forum Mobile Java General
    Replies: 1
    Last Post: 2007-01-11, 16:50
  4. Replies: 1
    Last Post: 2006-08-30, 10:10

Posting Permissions

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