Keil Logo

ARMCC: ARE WIDE CHARACTER (UNICODE) STRINGS SUPPORTED


Information in this article applies to:

  • RealView C Compiler Version 3

QUESTION

Does MDK-ARM support unicode characters?

When I build the following test program:

#include <wchar.h>
#include <wctype.h>

void wide_ch_test(void)    {
  wchar_t str1[] = L"Size of message is: ";
  wchar_t str2[80];

  swprintf(str2,sizeof(str2)/sizeof(wchar_t),L"%s",str1);
  gputsw(str2);         //Print a wide char message onto LCD
}

The line with swprintf function call fails with the warning:

warning:  #181-D: argument is incompatible with
                  corresponding format string conversion

ANSWER

Wide characters are fully supported. However, you must use the correct format string. Instead of #%s", use #%ls". In your example, change the swprintf function call line to:

swprintf (str2, (sizeof(str2)/sizeof(wchar_t)), L"%ls", str1);

SEE ALSO

Last Reviewed: Tuesday, May 17, 2011


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.