Results 1 to 2 of 2

Thread: Problem when passing an argument of UTF8 to evaluateJavaScript function

  1. #1
    Join Date
    Oct 2012
    Posts
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Problem when passing an argument of UTF8 to evaluateJavaScript function

    HI ,


    I want to pass UTF8 string as an argument to evaluateJavascript , but when i am passing the string i am getting parse error in JSconsole

    frame->evaluateJavaScript(QString("socketDataReceived('% 1','%2')").arg(pi).arg(str_new));


    The second qrgument str_new contains UTF string "GET /auth_ok HTTP/1.1
    Host: 127.0.0.1:31415
    User-Agent: Wget"



    The JS function which we are calling

    function socketDataReceived(type, req)
    {
    dbg("Notification Received:"+req);
    dbg("Notification Received: of datatype"+typeof(req));
    try
    {
    var response = "N/A";

    if(req == null || req == "")
    {
    dbg("\033[33mUnknown request, ignoring this request\033[0m");
    parent.piServerSend(response);
    return;

    }

    var reqcommand;
    var reqheaders;
    var reqcmdparts;
    var reqparms = [];
    var reqparmparts;
    var reqparams = [];
    var pump;
    var savedTransport;
    var response;
    var host;

    reqheaders = req.split("\n");

    if(reqheaders.length > 1)
    {
    reqcommand = reqheaders[0].split(' ');
    }
    else
    {
    parent.piServerSend(response);
    return;
    }

    if(reqcommand.length > 1)
    {
    reqcmdparts = reqcommand[1].split('?');
    }



    Please help me how to pass UTF8 string as a argument in evaluateJavascript function


    Thanks&Regards
    Chaitu

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Problem when passing an argument of UTF8 to evaluateJavaScript function

    Will this QString::toUtf8() help?
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

Similar Threads

  1. How to pass an argument to evaluateJavaScript function?
    By TheIndependentAquarius in forum Qt Programming
    Replies: 5
    Last Post: 5th January 2013, 10:45
  2. Passing argument to slot.
    By TCB13 in forum Newbie
    Replies: 2
    Last Post: 22nd February 2012, 20:52
  3. onclick event passing argument to js function
    By dyngoman in forum Qt Programming
    Replies: 0
    Last Post: 10th September 2011, 14:51
  4. Trouble passing an argument
    By benlyboy in forum Newbie
    Replies: 5
    Last Post: 9th May 2010, 23:49
  5. QtScript : passing array as argument into function
    By derek_r in forum Qt Programming
    Replies: 4
    Last Post: 27th October 2007, 11:46

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.