473,385 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

jason_encode fails with special characters

Claus Mygind
571 512MB
I have a user that typed the following into an input field

set 30º

This data was stored in the table using software other than php.

Now I am writing some new access code in php and while the data is retrieved from the table correctly, the ajax response returns a null value for that column/field (see photo look for "PRJCTADDR1")

I return a response to the client like so through jason_encode:
echo json_encode($res_array);

The client gets a null value, see attached photo (again look for "PRJCTADDR1".

Is there some standard routine to strip this and other characters from the data stream or otherwise escape these value?

What values should I be on the lookout for?
Attached Images
File Type: jpg degree mark there.jpg (42.5 KB, 189 views)
File Type: jpg degree mark null value.jpg (20.1 KB, 211 views)
Dec 12 '11 #1
6 2472
Claus Mygind
571 512MB
Just a followup, just to confirm this is a jason_encode problem. Here is the formatted value of the encode.

[{...,"PRJCTNAME":"Proposed Multi-Legged Water Tower","PRJCTADDR1":null,.....}]
Dec 12 '11 #2
Claus Mygind
571 512MB
A partial answer is to use htmlentities(string) to encode any string to be included in the json response array. However now I need to decode the result on the client where I now get this answer:

"PRJCTADDR1":"with Legs offset 30º"
Dec 12 '11 #3
Dormilich
8,658 Expert Mod 8TB
you could try urlencode() in PHP and decodeURIComponent() in JS.
Dec 13 '11 #4
Claus Mygind
571 512MB
Ah! This is occurring in the response to an ajax call in a simple data field. The "htmlentities(string)" works very well.

But the decodeURIComponent() sounds like a good idea.

Thanks for your response.

BTW, you steered me toward EventBug. Seems to be broken with FireFox 8. You got any alternate ideas to put in another great tool like that?
Dec 13 '11 #5
Dormilich
8,658 Expert Mod 8TB
But the decodeURIComponent() sounds like a good idea.
but it can't unescape entities, only %-escapes

BTW, you steered me toward EventBug. Seems to be broken with FireFox 8. You got any alternate ideas to put in another great tool like that?
I know it's a bother. currently I don't have a replacement. I only can hope that it will be supported in FF 9+
Dec 14 '11 #6
Claus Mygind
571 512MB
Ok thanks, I will work on that
Dec 16 '11 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Roy W. Andersen | last post by:
I've been searching google about this for days but can't find anything, so I'm hoping someone here can help me out. I'm trying to create zip-files without needing the zip-file extension in PHP,...
3
by: Barry Olly | last post by:
Hi, I'm working on a mini content management system and need help with dealing with special characters. The input are taken from html form which are then stored into a varchar column in...
0
by: Malte Boerner | last post by:
Hi there, we have a problem validating xml with the Multi-Schema-Validator from Sun. If we have special characters like ö from the character-set ISO-8859-1 in the content of an xml-tag, the...
3
by: Jens Kristensen | last post by:
I have a problem displaying a divbox containing a html-textarea - everything works fine with "normal" characters. However, when the textarea contains special chars like <P> or ' , the box fails to...
5
by: Sakharam Phapale | last post by:
Hi All, I am using an API function, which takes file path as an input. When file path contains special characters (@,#,$,%,&,^, etc), API function gives an error as "Unable to open input file"....
17
by: Carl Mercier | last post by:
Hi, Is it possible to use special characters like \n or \t in a VB.NET string, just like in C#? My guess is NO, but maybe there's something I don't know. If it's not possible, does anybody...
2
by: Alan Searle | last post by:
For reporting purposes I generate XML from an MS-Access 2002 database and find that in this way I can format and display the data no problem with a XSL/HTML template. Perfect! However, then I...
8
by: david.lindsay.green | last post by:
Hello all, I am quite new a web scripting and making web pages in general and I have stumbled across a problem I have as yet been unable to solve. I am trying to take the contents of a textarea box...
1
by: Zvonko Bi¹kup | last post by:
Hi! I want to check the text field if it contains only alphanumerical values and not space. But I use special characters in croatian language (iso-8852-2) and when you enter such a charactzer,...
3
KevinADC
by: KevinADC | last post by:
Purpose The purpose of this article is to discuss the difference between characters inside a character class and outside a character class and some special characters inside a character class....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.