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: 27
Registered: ‎04-01-2009
My Device: Not Specified
Accepted Solution

Share invocation and the pound sign

Hi, 

 

In qml I am trying to share a message which contains a pound sign "£" but this charcacter gets corrupted :

 

Invocation {
    id: share
    query: InvokeQuery {
        mimeType: "text/plain"
        id: idQuery
        invokeActionId: "bb.action.SHARE"
    }
    onArmed: {
        if (idQuery.data != "") {
            trigger("bb.action.SHARE");
        }
    }
}

 

Any one got any ideas? I've tried using a mime-type like this: "text/plain;charset=utf-8" but without success.

Highlighted
Developer
Posts: 27
Registered: ‎04-01-2009
My Device: Not Specified

Re: Share invocation and the pound sign

I managed to find an answer to my question which may not be the best way to do it but it works for me. It also allows extended characters to be posted to such as "éüâ" to be shared to.

 

I expose a function in C++:

 

Q_INVOKABLE static QByteArray fromUnicodeToLocale(const QString &str);

 

QByteArray Utils::fromUnicodeToLocale(const QString &str) {
    return QTextCodec::codecForLocale()->fromUnicode(str);
}

 

Then in qml:

 

Invocation {
    id: share
    query {
        mimeType: "text/plain"

        data: _utils.fromUnicodeToLocale("My Café: tea £1.60")
        id: idQuery
        invokeActionId: "bb.action.SHARE"
    }
    onArmed: {
        if (share.query.data != "") {
            trigger("bb.action.SHARE");
        }
    }
}