LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

"warning: illegal character encoding in string literal"

Solved!
Go to solution

I'm running CVI 2015, v15 (408).

 

On some old projects wherein I put extended ASCII characters into string controls, I'm now getting the above warnings.  Any idea where I can quiet some of these warnings?

0 Kudos
Message 1 of 7
(28,628 Views)
Solution
Accepted by topic author ElectroLund

Hi,

 

clang should tell you its warning flag [-Winvalid-source-encoding] which you can turn off as is described here. (it's the eleventh entry in the list)

Message 2 of 7
(28,618 Views)

Sorry to revive quite an old thread, but is there any other solution apart hiding the warning?

 

The problem with special characters is that even if you can write them in UTF-8 so that the compiler does not complain any more, the resulting text is not what you expect.

 

As an example, the message "0 ÷ 7.5V ac" (which is a short form for "0 through 7.5V") can be encoded this way "0 \343\267 7.5 V ac." to avoid the compiler warning but unfortunately results in this message on screen:

 

Screenshot 2016-08-31 11.29.22.png

 

 

(Unless the problem is on my side: I made the conversion to UTF-8 according to this Wikipedia page considering '÷" character as U+00F7 as shown by Windows charmap application, but I could make some error).



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 3 of 7
(27,054 Views)

Hmm, I'm not having success with that symbol either, Roberto.  Curious.

0 Kudos
Message 4 of 7
(27,046 Views)

Hello Roberto,

 

Even if clang expects the strigs to be UTF-8, cvi run-time treats them as ANSI. The "Invalid source encoding" warning should really be ingnored and it was a mistake introducing it in CVI 2015.

If you want the "÷" symbol you should encode it as Ansi(e.g. 0xF7 in Western code page). If the text is a string passed to MessagePopup, the problem is on another computer with different locale 0xF7 could represent a different symbol and display differently. If you want you text to look the same on all computers you can use a Text Message control and set the Character set to one that supports that symbol. See this thread for more details

Message 5 of 7
(26,964 Views)

Thanks Constantin, that was what I was looking for: I can get rid of the warning without the risk of masking some problem in the code.

Since I started using CVI2015 I became aware of a series of warnings that in previous versions weren't raised by the compiler (or is maybe clang which is more meticulous?). I am changing the way I am coding to avoid the maximum warnings I can in the hope that it makes the code more robust and safer, so I am trying to understand the extent of every warning I see in the build output window.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 6 of 7
(26,960 Views)

I do something like this; for the degree symbol and F for Fahrenheit:

 

char degreesF[3];
Fmt (degreesF,"%s<%cF", 186);  

Using degreesF in a strings results in °F without errors.

Message 7 of 7
(21,589 Views)