Chris Brody created CB-9435:
-------------------------------
Summary: cordova-ios cannot handle Unicode U+2028 (line separator)
or U+2029 (paragraph separator)
Key: CB-9435
URL: https://issues.apache.org/jira/browse/CB-9435
Project: Apache Cordova
Issue Type: Bug
Components: iOS
Reporter: Chris Brody
In https://github.com/litehelpers/Cordova-sqlite-storage/issues/147 someone
reported that my sqlite plugin could not handle \u2028 characters on iOS, and
further testing on my part isolated this to the result callback message. I made
a version of cordova-ext-echo at
https://github.com/brodybits/cordova-ext-echo-and-length that can be used to
demonstrate this issue cordova-ios.
If I install the plugin from
https://github.com/brodybits/cordova-ext-echo-and-length and run the following
code on the iOS version:
var Echo = cordova.require('org.apache.cordova.plugins.echo.Echo');
Echo.echo('first\u2027second', function(v) {
console.log('cb 1: ' + v);
});
Echo.echo('third\u2028fourth', function(v) {
console.log('cb 2: ' + v);
});
Echo.echo('fifth\u2029six', function(v) {
console.log('cb 3: ' + v);
});
Echo.len('first\u2027second', function(v) {
console.log('len cb 1: ' + v);
});
Echo.len('third\u2028fourth', function(v) {
console.log('len cb 2: ' + v);
});
Echo.len('fifth\u2029six', function(v) {
console.log('len cb 3: ' + v);
});
I get the following result:
2015-07-31 01:21:11.968 cijt[25760:18e03] cb 1: first‧second
2015-07-31 01:21:11.971 cijt[25760:18e03] len cb 1: 12
2015-07-31 01:21:11.973 cijt[25760:18e03] len cb 2: 12
2015-07-31 01:21:11.973 cijt[25760:18e03] len cb 3: 9
We can see that we can send a string with U+2028 and U+2029 from Javascript to
Objective-C with no problems: if Objective-C calculates and returns the length
it works but if Objective-C tries to send the same string back to Javascript it
fails.
I discovered the following article that seems to describe the cause:
http://timelessrepo.com/json-isnt-a-javascript-subset (Cordova does seem to
handle the \u000A and \u000D characters OK.)
When I ran the same test program on Android (with the same plugin installed), I
get all of the callbacks ok (trace filtered by hand):
I/chromium(14744): [INFO:CONSOLE(173)] "cb 1: first‧second", source:
file:///android_asset/www/plugins/cordova-plugin-console/www/console-via-logger.js
(173)
I/chromium(14744): [INFO:CONSOLE(173)] "cb 2: third
fourth", source:
file:///android_asset/www/plugins/cordova-plugin-console/www/console-via-logger.js
(173)
I/chromium(14744): [INFO:CONSOLE(173)] "cb 3: fifth
six", source:
file:///android_asset/www/plugins/cordova-plugin-console/www/console-via-logger.js
(173)
I/chromium(14744): [INFO:CONSOLE(173)] "len cb 1: 12", source:
file:///android_asset/www/plugins/cordova-plugin-console/www/console-via-logger.js
(173)
I/chromium(14744): [INFO:CONSOLE(173)] "len cb 2: 12", source:
file:///android_asset/www/plugins/cordova-plugin-console/www/console-via-logger.js
(173)
I/chromium(14744): [INFO:CONSOLE(173)] "len cb 3: 9", source:
file:///android_asset/www/plugins/cordova-plugin-console/www/console-via-logger.js
(173)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]