Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 813
Registered: ‎05-29-2012
My Device: see later
My Carrier: see later
Accepted Solution

Reading arabic letters from server side

I see them turning to crzy stuff, like a circle..word cut...

 

when i am defining in mty .ts file its reading arabic write..but when i get value from server side its writing crazy stuff

Developer
Posts: 543
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....
My Carrier: Telekom Slovakia

Re: Reading arabic letters from server side

[ Edited ]

Are you tried QTextCodec?

EDIT:

Or example how you do?



If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog
Developer
Posts: 813
Registered: ‎05-29-2012
My Device: see later
My Carrier: see later

Re: Reading arabic letters from server side

how do i implement that? i ididnt try that
Developer
Posts: 543
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....
My Carrier: Telekom Slovakia

Re: Reading arabic letters from server side

QTextCodec::setCodecForCStrings(QTextCodec::codecForName("utf8"));

 Put this to your constructor of the app class, for example.

Also you can try set the ContentType header for the request to text/html; charset=utf-8

 

Can you provide the code how do you do?

 



If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog
Developer
Posts: 813
Registered: ‎05-29-2012
My Device: see later
My Carrier: see later

Re: Reading arabic letters from server side

void ApplicationUI::onRegionalStoresLoaded2()
{

	try
	{

		QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());


		QString response;
		if (reply) {
			if (reply->error() == QNetworkReply::NoError) {
				const int available = reply->bytesAvailable();
				if (available > 0) {
					const QByteArray data(reply->readAll());
					//	QVariant jsonva(QString(data)); //= Json::parse(QString(data), true);
					// JsonDataAccess json = JsonDataAccess::loadFromBuffer(QString(data));
					JsonDataAccess jda;
					QVariant jsonva = jda.loadFromBuffer(QString(data));
					//QVariantList list = jsonva.toList;
					QVariant list = jsonva;
					emit readRegionalStores2(list);

				}
			}
			reply->deleteLater();

		}
	}
	catch(...)
	{

	}
}

 

void ApplicationUI::readRegionalStores2(QVariant list) {
	try
	{

		//QVariantMap map;
		ActivityIndicator *mActivityIndicator = root->findChild<
				ActivityIndicator*>("activityIndicatorRegionalStores2");
		if (mActivityIndicator != NULL)
			mActivityIndicator->stop();
		QVariantMap childJsonv1a = list.toMap();


		QVariant status = childJsonv1a["STATUS"];

		ListView* accountDetailsSubList = root->findChild<ListView*>("regionalStoresList2");
		bb::cascades::QVariantListDataModel *listModelsf  =
				new QVariantListDataModel();

		if(status == "1000")
		{
			QVariantMap childJsonva2 = childJsonv1a["DATA"].toMap();
			QVariant childJsonva = childJsonva2["STORES"];
			QVariantList childList = childJsonva.toList();
			if (accountDetailsSubList != NULL) {

				QVariantMap map;
				for (QList<QVariant>::iterator it = childList.begin();
						it != childList.end(); it++) {
					map = it->toMap();
					listModelsf->append(map);


				}

			}

			if (accountDetailsSubList != NULL)
				accountDetailsSubList->setDataModel(listModelsf);

		}

	}
	catch(...)
	{

	}

}

 

here is code, i read a josn file

 

 

ma["NAME"] in arabic starts giving me different results on screen...

Developer
Posts: 813
Registered: ‎05-29-2012
My Device: see later
My Carrier: see later

Re: Reading arabic letters from server side

thank you what you give me to put in constructor, it worked with it.
Developer
Posts: 543
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....
My Carrier: Telekom Slovakia

Re: Reading arabic letters from server side

You're welcome Smiley Wink



If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog
Highlighted
Developer
Posts: 813
Registered: ‎05-29-2012
My Device: see later
My Carrier: see later

Re: Reading arabic letters from server side

this solved issue, thanks alot for it

 

QTextCodec::setCodecForCStrings(QTextCodec::codecForName("utf8"));