Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8060709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:04:54+00:00 2026-06-05T10:04:54+00:00

I finally overcame the problem of passing full utf-8 strings from javascript to python,

  • 0

I finally overcame the problem of passing full utf-8 strings from javascript to python, but now the carriage return "\n" which is present on the Javascript side is missing when the string is received in python. Is there something I’m supposed to do to achieve this?

function saveMeetingComments(){
    var komments = $('#cmt_t').val()
    var d = new Date();
    var commentsText  = $('#cmt_t').val()
    var abc = ''
    var request = par_makeHttpObject();
    commentsText = stringTranslate(commentsText,"'",'`');
    request.open("POST", "saveMeetingNote?clientID="+clid_+
             "&co_ID="+coid_+
             "&msgDate="+dateFormat(d, "dddd, mmmm dS, yyyy, h:MM TT")+
             "&MeetType="+AGM_+
             "&MeetDate="+meetdate+"-"+
             "&Comments="+commentsText , false);
    request.send();
    $('#cmt_t').val('');
    parkAll();
}

Comments is the only variable which may have carriage returns. On the Python side the code is as follows:

def saveMeetingNote(self, **kwargs):
    clientID         = kwargs['clientID']
    co_ID            = kwargs['co_ID']
    MessageDate      = kwargs['msgDate']
    MeetingType      = kwargs['MeetType']
    MeetingDate      = kwargs['MeetDate']
    Comments_        = kwargs['Comments']
    coName = dennislib.CompanyCoID2NAME(co_ID)[0]['FName']
    ret = dennislib.saveMeetingNotes(clientID,co_ID,MessageDate,MeetingType,MeetingDate,Comments_,coName)
    return 
saveMeetingNote.exposed = True

Inspecting Comments_ shows that the \n are all gone…

TIA

Dennis

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T10:04:55+00:00Added an answer on June 5, 2026 at 10:04 am

    Looks like you’re not URL-encoding the data before sticking it in the POST request URL. Newlines aren’t the only thing which could be lost. What happens when someone types an & in the comment field?

    Use encodeURIComponent to fix this:

    // ...
    "&Comments=" + encodeURIComponent(commentsText)    // ...
    

    On the server side, to decode this use:

    import urllib
    # ...
    Comments_ = urllib.unquote(kwargs['Comments']).decode('utf-8'))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Finally I have decided to get rid of aptana from eclipse but the Software
Finally deployed my ruby on rails 3.2 app but when trying to open it
Finally figured it out thanks to One Mad Monkey, but forgot quotes on my
Finally I managed to get pylucene working on my windows7 machine, Which raised a
I finally had success passing data through AJAX and returning it in JSON. However,
I finally got some parts working here: http://jsfiddle.net/trXBr/5/ but when I put the code
I finally found a way to remove get parameters from my urls i had
I finally found a nice javascript count up timer with no frills. I would
I finally thought I had found a way to acutally use excel productively but
I finally finished coding my Android calculator after so long. But the calculator won't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.