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: 64
Registered: ‎09-10-2012
My Device: Developer
My Carrier: AMX
Accepted Solution

Accented characters not displayed correctly

Hi guys

 

In my app i got a .json file encoded in ANSI, which contains characters such as áéíóú. The interface has a ListView which loads data from the json.

In Beta 2, The texts were displayed correctly, but in Beta 3, the special characters are displayed as a box with an X on the device and on simulator.

 

If I encode the file to UTF-8, nothing i shown on the ListView, and this is displayed in the log:

JSON ERROR :  "* Line 1, Column 1 Syntax error: value, object or array expected.

 

The json file is loaded in C++ with this code:

bb::data::JsonDataAccess jda;
QMap<QString, QVariant> jsonCont = jda.load("data/file.json").toMap();
QVariantList lst = jsonCont.value("items").toList();

dataModel = new GroupDataModel(QStringList() << "title");
dataModel->setParent(this);
dataModel->insertList(lst);
dataModel->setGrouping(ItemGrouping::None);
if(listView) listView->setDataModel(dataModel);

 

The texts are loaded in the ListItems with this QML code:

Label {
            text: ListItemData.title

}

 

I have searched the forums and found this Special Characters thread, but It does not solve my problem.

 

I'd really appreciate any ideas.

 

José Ugalde

Developer
Posts: 526
Registered: ‎05-17-2009
My Device: 9900
My Carrier: ATT

Re: Accented characters not displayed correctly

Looks like its saying that your json file is misformatted, not that your accented characters are a problem.

Like all of my posts
Highlighted
Developer
Posts: 64
Registered: ‎09-10-2012
My Device: Developer
My Carrier: AMX

Re: Accented characters not displayed correctly

I generate the json file with a Python script. It is created in ANSI (which works in Cascades but does not display accents). I open the file in Notepad++, convert the encoding to UTF-8.

 

I uploaded the file and tested it in http://jsonlint.com/

The output was:

 

Parse error on line 1:

{     "baseimgurl":

^

Expecting '{', '['

 

It was the BOM mark... now I encode them in UTF-8 without BOM and it displays accents.

 

Thanks!