Single quote in JSON return from MySQL gets changed to special character when returned to Flutter call

Viewed 398

I am facing an issue, where a single quote/apostrophe that is in a string and then sent to a nodejs rest api and then is inserted into a JSON field in MySQL, when I get the same JSON and return to a call made from Flutter, the JSON looks right when I curl, it also looks right when I print it out. I use restify and res.json(json), when flutter gets the response.body the single quote is now some special character "a with a shift 6 over the top". I have tried replace, stringify but do not understand why it is changed, it does not happen on the way out which makes me think its flutter, but can not find how or how to handle it.

Anyone with ideas would be great, let me know any code you want to see.

{"oid":1,"pid":1,"sub":"Re: Sarah Doe","prid":"1","oname":"Referring Doctor","pname":"Amar Patel","msgkey":"d47f6e81-8c8e-4209-a073-03a8d2e79356","pgrpid":"1","sender":"o","message":"This is to test the apostrophe that can’t be used","fcmtoken":null,"receiver":"p","sendname":"Referring Doctor","submitdate":"2017-11-06 05:24:25.015089","receivename":"Amar Patel","referralname":"Sarah Doe"}

It never changes, it always looks like this, I have tried to

replace("'","\'") 

I have also tried

replace(/\'/g, '"')

This is code in one of its many iterations

for (var i = 0; i < results.length; i++) {
                //console.log('****RESULT****CHAT***: ', results[i].chat);
                var myrecord = results[i].chat;
                //console.log('MYRECORD: '+myrecord);
                //console.log('MYRECORD-STRING: '+JSON.stringify(myrecord));
                var json = myrecord.replace(/\'/g, '"');
                //console.log('JSON-REPLACE: '+json);
                myjson.push(JSON.parse(json));

            }

Nothing seems to affect the single quote that is in the message node.

1 Answers

This is related to iOS 11 and the addition of smart punctuation. Because of that a curly quote is sent and not a true single quote. Unfortunately it is not exposed to turn it off, right now you have to choose a url or email keyboard where it is turned off.

Related