Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Invalid Character inretrieved string

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
SteveJ
Smarty n00b


Joined: 04 Mar 2016
Posts: 3

PostPosted: Fri May 12, 2017 7:43 pm    Post subject: Invalid Character inretrieved string Reply with quote

Hello
I'm retrieving an image from an SQL database as a BLOB and using a smarty template to process it. I get an invalid character error when I try to pass the retrived data to a javascript parameter. Essentially this is because the retrieved data contains non printing characters.

Is there any way I can get round this problem?

Code:

      <script>
      {literal}
      var markers = [
      {/literal}{foreach item=Row from=$DataGrid.Rows}{literal}
      {
         "date": '{/literal}{$Row.DataCells.MapDate.Value}{literal}',
         "lat": {/literal}{$Row.DataCells.Latitude.Value}{literal},
         "lng": {/literal}{$Row.DataCells.Longitude.Value}{literal},         
         "image": "{/literal}{$Row.DataCells.Image.Value}{literal}",
         "description": "{/literal}{$Row.DataCells.Comments.Value}{literal}",
         "type": "{/literal}{$Row.DataCells.Type.Value}{literal}"
      },
      {/literal}{/foreach}{literal}      
      ];
      
         
         {/literal}
         </script>


SteveJ
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sat May 13, 2017 1:36 pm    Post subject: Re: Invalid Character inretrieved string Reply with quote

Escape the string properly.
Back to top
View user's profile Send private message
SteveJ
Smarty n00b


Joined: 04 Mar 2016
Posts: 3

PostPosted: Sat May 13, 2017 1:59 pm    Post subject: Re: Invalid Character inretrieved string Reply with quote

AnrDaemon wrote:
Escape the string properly.


Useful answer for a complete newbie. How?

SteveJ
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sat May 13, 2017 4:36 pm    Post subject: Reply with quote

No idea. Google "javascript string special characters escaping" or something.
This is not a Smarty question, for Smarty, all the data it output is equal and lacks any meaning outside trivial byte stream.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP