PLUS+1 Hardware > Displays

Generating unicode symbols in C POUs (DM430E)

(1/2) > >>

I'm attempting to generate some strings from within a POU that include unicode symbols like the Degree symbol and the Greater-Than-Equal symbol.

I've tried a few different things so far, but nothing has worked.

Basically, I want to take the output of a POU and than insert that into a Screen Definition as a STRING.  Is this possible?

I've done this before with a POU, there are two ways I've used.

1. Use a Structured Text POU to work with strings as it is a supported data type, although string/wstring is referred to as a char/wchar. This signal should be able to be directly connected to a screen definition.
2. If you use a C POU, then you need to use an array as the output of the POU instead of a string. After the POU the signal then needs to have a retype to string before it can be connected to a screen definition.


I'm actually able to work with STRINGs in C-POUs, but run into issues when I try to use WSTRINGs which would support characters that are outside of the base ASCII set.

Using STRING to try to print the degree symbol gives me the following warning and will compile but won't print correctly once it's installed and running on the display.
   - illegal character encoding in string literal In: wDiagSignals Line: 282 Column: 38 Category: Lexical or Preprocessor Issue

Using WSTRING and running the output of the POU directly to the Screen Definition gives me the following compile-time error.
   [CHPARGU1] Unsupported POU Call: {POU: wDiagSignals cannot be called directly from GUIDE code because it is using unsupported interface item(s): wstring, }.

Can WSTRINGs be used this way with ST-POUs?  It seems like it's specifically a limitation of the graphical portion of the environment rather than a C-POU vs ST-POU thing.  I will do some testing with ST-POUs today.

I think it may be a limitation of the Graphical environments data types. Since GUIDE is limited to UTF-8 encoding for strings and it has to be converted from an array to a string.
I did get it working in C using the UTF-8 encoding and then converting it to a string like in the image I've attached.

I think the ST POU has an advantage then since it can directly handover a WString to the VBSE interface. The String Examples page in the help makes it seem like it should be nicer.

Well, I tried routing a WSTRING across from the ST POU without success. So I guess that won't work.
Using the function to converting it to a string worked though.

  sMyString : STRING[20];
  sTempString : WSTRING[10];

sTempString := "┬░Test 12 %";
sMyString := WSTRING_TO_STRING(sTempString);


[0] Message Index

[#] Next page

Go to full version