This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

swprintf with wide characters on NRF52840

Hi,

I am trying to render some chinese strings on an OLED display. For this I would like to concatenate some strings using swprintf.

But when the replacement string contains wide characters, it does not work.

wchar_t* name = L"约翰";
wchar_t sentence[24] = {};

swprintf(sentence, 24, L"Hi my name is %ls", name);
// Produces -> "Hi my name is "

On the other hand if I concatenate like this, it works.

wchar_t* name = L"约翰";
wchar_t sentence[24] = {};

wcscat(sentence, "Hi my name is ");
wcscat(sentence, name);

// Produces -> "Hi my name is 约翰"

I noticed that there is an option in SEGGER studio to enable wide character support for printf/scanf.

But when I try to enable it I always get this error:

"/Applications/SEGGER Embedded Studio for ARM 4.16/gcc/arm-none-eabi/bin/ld:--defsym:1: undefined symbol `__vfprintf_short_float_long_wchar' referenced in expression"

Is there any way to get it to work?

Thanks!

Parents Reply Children
No Data
Related