2019-05-17 03:32 AM
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!
2019-05-17 04:44 AM
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
2019-05-20 01:41 AM
Hey,
Thanks for the suggestion, it works! But still, I've got no idea how I can convert a Unicode::UnicodeChar* to a double!
2019-05-20 01:58 AM
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