degree symbol

Hello,

I would like to insert a degree symbol
(super script ‘o’) into a label string
from photon source code.

My (possibly naive) attempt:


char str[64];

sprintf(str," temp: %d %cC", 45, 0xb0);
PtSetResource( ABW_PtLabel_bla, Pt_ARG_TEXT_STRING, str, 0);



Is this the right way? If not how should this be done.

Michel Benoit
Saab Communication

That attempt did not work!

Photon requires Unicode encoding for widgets. Anything > 127 is
considered to be the first byte of a multibyte sequence. See ‘UTF-2’
encoding in docs.

  • igor

Michel Benoit wrote:

Hello,

I would like to insert a degree symbol
(super script ‘o’) into a label string
from photon source code.

My (possibly naive) attempt:

char str[64];

sprintf(str," temp: %d %cC", 45, 0xb0);
PtSetResource( ABW_PtLabel_bla, Pt_ARG_TEXT_STRING, str, 0);

Is this the right way? If not how should this be done.

Michel Benoit
Saab Communication

Igor Kovalenko <Igor.Kovalenko@motorola.com> wrote:

Photon requires Unicode encoding for widgets. Anything > 127 is
considered to be the first byte of a multibyte sequence. See ‘UTF-2’
encoding in docs.

What he said. Plus, you can use wctomb() to convert Unicode to
multibyte – the character you were talking about, L’\xB0’, converts to
a two-byte sequence “\xC2\xB0”.

If you know how to type the required character on your keyboard, you can
also enter it directly into your code using ped: ped is a Photon
application and stores characters as UTF by default. (But do not use
a text-based editor in a pterm to enter non-ASCII characters –
text-based editors don’t support UTF and you will most likely end up
with invalid multibyte sequences.)


Wojtek Lerch (wojtek@qnx.com) QNX Software Systems Ltd.