Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-13600] BlackBerry: JSON Parser is not parsing extended character like used in Arabic correctly

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionDuplicate
Resolution Date2013-04-20T06:07:29.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsBlackBerry
Labelsn/a
ReporterRussell McMahon
AssigneeJosh Roesslein
Created2013-04-17T01:04:52.000+0000
Updated2017-03-16T20:23:13.000+0000

Description

var MyGlobalVars = {
token: null,
userid: null,
city: null
};

// create first window - login window -
// if success in login redirect to home window
var windowLogin = Ti.UI.createWindow({
backgroundColor : "#A8111B",
});
// create form login
var username = Ti.UI.createTextField({
color : '#336699',
top : 10,
width : 200,
textAlign : 'center',
height : 40,
hintText : 'اسم المستخدم'
});

var password = Ti.UI.createTextField({
color : '#336699',
top : 40,
width : 200,
height : 40,
textAlign : 'center',
passwordMask : true,
hintText : 'كلمة المرور'

});

var buttonLogin = Ti.UI.createButton({ title : 'تسجيل الدخول', textAlign : 'center', top : 90, height : 40, width : 100, right : 20 });

var buttonRegister = Ti.UI.createButton({ title : 'مستخدم جديد', textAlign : 'center', top : 130, height : 40, width : 100, right : 20 });

var buttonForget = Ti.UI.createButton({ title : 'نسيت كلمة المرور', textAlign : 'center', top : 170, width : 100, height : 40, right : 20 });

// redirect to show window on click
buttonRegister.addEventListener("click", function() { Titanium.include('ui/register.js'); });

// redirect to show window on click
buttonForget.addEventListener("click", function() { Titanium.include('ui/forget.js'); });

var loginReq = Titanium.Network.createHTTPClient();
buttonLogin.addEventListener('click', function(e) {

if (username.value != '' && password.value != '') {
loginReq.open("POST", "http://demoo.smaris.net/keftaltareq/user_json/login");
var params = { username : username.value, password : password.value };
loginReq.send(params);

} else { alert("username and password are required"); }

});

loginReq.onload = function() {

var json = this.responseText;
var response = JSON.parse(json);
if (response.success == 1) { //windowLogin.close() MyGlobalVars.token = response.token; MyGlobalVars.userid = response.id; Titanium.include('ui/index.js'); } else if (response.success == 2) { alert("خطأ باسم المستخدم أو كلمة المرور"); }

};

windowLogin.add(username);
windowLogin.add(password);
windowLogin.add(buttonLogin);
windowLogin.add(buttonRegister);
windowLogin.add(buttonForget);

windowLogin.open();

// and this is my code for data returned from server

openCityBtn.addEventListener('click', function(e) {
var getCity = Titanium.Network.createHTTPClient({
onerror : function(e) { Ti.API.debug(e.error); alert('حدث خطأ اثناء الاتصال'); },
timeout : 5000,
});

getCity.open('GET', 'http://demoo.smaris.net/keftaltareq/user_json/city_blackberry/' + MyGlobalVars.userid + '/' + MyGlobalVars.token);
getCity.send();
getCity.onload = function() {
var json = JSON.parse(this.responseText);
dataArray = [];
for (var i = 0; i < json.length; i++) {
var row = Ti.UI.createTableViewRow({ title : json[i].city_name_en });
dataArray.push(row);
};
tableX.setData(dataArray);
};

var view = Titanium.UI.createView({ backgroundColor : '#3D3D3D', borderColor : '#fff', borderWidth : 4, width : 200, top : 5, height : 150 });

var tableX = Titanium.UI.createTableView({ backgroundColor : 'transparent', separatorColor : 'black', textAlign : 'right', });

view.add(tableX);
winHome.add(view);

tableX.addEventListener('click', function(e) { view.hide(tableX); MyGlobalVars.city = e.rowData.title; });

});

Comments

  1. Josh Roesslein 2013-04-20

    I believe the issue was with TableViewRow.title not handling the unicode characters, not the JSON parsing. There is a fix that was just pushed that fixes the issue with "title". I am not able to run this sample since it requires credentials. A CI build should appear shortly [here](http://builds.appcelerator.com.s3.amazonaws.com/index.html#master) with this fix included. If you could verify the issue goes away the latest build. If the issue persists please re-open.
  2. Josh Roesslein 2013-04-20

    Duplicate of TIMOB-13638.
  3. Lee Morris 2017-03-16

    Closing ticket as BlackBerry is no longer supported by us.

JSON Source