cancel
Showing results for 
Search instead for 
Did you mean: 

Unicode to double and display a double in a textArea

GMeur
Senior

Hello,

How can I convert a Unicode::UnicodeChar* to a double ? I've only found the function "atoi" to convert it to an 'int'.

And also, how can I display a double in a textArea as such :

Unicode::snprintf(textArea1Buffer, 10, "%f", 2.5);

Thanks in advance!

3 REPLIES 3
d.v.
Associate II

Hi,

you can try with

Unicode::snprintfFloat(textAreaValBuffer, TEXTAREAVAL_SIZE, "%#1.1f", 2.5);

I use it for float, maybe works also for double,

Other info in Unicode.hpp file

Hope it helps

GMeur
Senior

Hey,

Thanks for the suggestion, it works! But still, I've got no idea how I can convert a Unicode::UnicodeChar* to a double!

Martin KJELDSEN
Chief III

Hi @GMeur​,

Here's a simple method to convert Unicode to ASCII - This works because the Unicode array is zero terminated.

static void convertUnicodeToAscii(Unicode::Unicode* in, uint8_t* out){
    while(*in != 0){
        *out++ = (uint8_t)*in++;
    }
    *out = 0;
}

Once you have your basic char array you can now convert using regular means.

/Martin