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
Highlighted
Developer
Posts: 207
Registered: ‎02-10-2011
My Device: Playbook 16GB and Z10
My Carrier: Verizon
Accepted Solution

International MBCS

I have a music app that pulls in a users music files and some of the music songs have characters other than English characters and they show up all garbled.  Is there a way to have these characters automatically converted to their correct display?

 

For example e with an accent looks like A^%$% or something similar.

_________________________________________________
Apps
Go Music
Flashlight Fast Free/Pro
Fitbit for BlackBerry PlayBook
Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: International MBCS

If the data is in UTF8, then the following should work:

QString s = QString::fromUtf8(byteArray.constData(), byteArray.size());

 

Default QString constructor treats it as Latin1, but it's possible to change the default encoding on application level:

 

QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));

 


Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 207
Registered: ‎02-10-2011
My Device: Playbook 16GB and Z10
My Carrier: Verizon

Re: International MBCS


Zmey wrote:

If the data is in UTF8, then the following should work:

QString s = QString::fromUtf8(byteArray.constData(), byteArray.size());

 

Default QString constructor treats it as Latin1, but it's possible to change the default encoding on application level:

 

QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));

 


This worked perfectly!  I just had to make sure when saving a string to my sqlite DB that I do the 

 

QString s = QString::fromUtf8(byteArray.constData(), byteArray.size());

 

_________________________________________________
Apps
Go Music
Flashlight Fast Free/Pro
Fitbit for BlackBerry PlayBook