ARM Technical Support Knowledge Articles

ARE WIDE CHARACTER (UNICODE) STRINGS SUPPORTED

Applies to: RealView C Compiler

Answer


Information in this article applies to:


QUESTION

Does MDK-ARM support unicode characters?

When I build the following test program:

#include 
#include 

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

Article last edited on: 2011-05-17 08:14:36

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential