-
Try out the new Jake: AI Coding Assistant for LabVIEW (beta)!
Get answers to questions about LabVIEW and discuss your code.
Details
Hello,
I'm french and on my french OS, commands returns are localized... and some caracters are not properly handled in StdOutput/StdError streams. For instance, with the ping example, I expect to get five "Réponse de 127.0.0.1...", and I get instead "R,ponse de 127.0.0.1..." (é is replaced by ,). This is only one example, others accentuated characters are not properly returned.
I've alreayd played with .Net, and I know it is possible to set encoding. In my case, using the CodePage 850, returned strings are just fine, with expected accentuated caracters.
So I'm convinced that having the default system encoding set in the @created VI should be a nice imporvement.
Option A. Add an optional parameter
It is possible to set it statically, or by passing the numeric CodePage value as an argument (if not specified, use defaut value).
It also ca be a ring, with human readable description of CodePage. But choosing the right encoding, in my case between ibm850/Western Europe (DOS), ibm852/Central Europe (DOS), IBM1147/IBM EBCDIC (France-Euro), has nothing straightforward for a developer (I mean, by someone non familiar with CodePages). See https://docs.microsoft.com/en-us/dotnet/api/system.text.encoding?view=net-5.0
Option B : Find a way to get the system CodePage programmatically
Instead of having one more parameter (even optional) or wondering what is tmy OS encoding, if the @create vi can handle this for me, that's perfect. Not so straightforward.
I find a post on StackOverflow that describes how the get the system default codepage (https://stackoverflow.com/questions/61211164/how-to-find-os-code-page-number-in-net-core) I managed to translate it into LabVIEW code, but it always returns the default CodePage 1252 / Western European (Windows), that returns me wrong caracters.
As last resort, I've build a code that launches cmd.exe with .Net connectivity functions, and executes the chcp command (https://docs.microsoft.com/fr-fr/windows-server/administration/windows-commands/chcp) With a bit of string parsing, I managed to get the numeric CodePage value, and to apply it to StartInfo, as StandardOutputEncoding and StandardErrorEncoding. But I found this method a bit messy.
What do you think about this ? Does someone have a better way to get the correct CodePage programmatically ?
Best regards,
Please sign in to leave a comment.