11-04-2015 04:15 PM
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?
Solved! Go to Solution.
11-04-2015 11:56 PM
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)
08-31-2016 04:35 AM - edited 08-31-2016 04:36 AM
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:
(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).
08-31-2016 08:27 AM
Hmm, I'm not having success with that symbol either, Roberto. Curious.
09-05-2016 04:24 AM
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
09-05-2016 04:35 AM
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.
10-23-2018 12:33 PM
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.