Skip to main content
GMeur
Associate III
May 17, 2019
Question

Unicode to double and display a double in a textArea

  • May 17, 2019
  • 3 replies
  • 947 views

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!

This topic has been closed for replies.

3 replies

d.v.
Associate
May 17, 2019

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
GMeurAuthor
Associate III
May 20, 2019

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
Principal III
May 20, 2019

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