Help! Is this problem Encoding or Localization?

A

Andrew

Hi Guys

I have a VS2008 C# Winforms application that uses SerialPort to
communicate with an embedded bit of kit. The physical connection is
via a USB using the Silicon Labs CP210X drivers.

The application sends status queries as an ASCII string to the
external device, CRLF terminated. The external device responds with
an ASCII string of data CRLF terminated. No coding was added (so I
presume defaults applied) to account for Encoding or Localization.

The application was develped in the UK, and has so far been
successfully deployed to systems in the UK, US, France, Spain,
Germany, Belgium and I believe Italy. In all these environments
things work exactly as expected.

We have just deployed to a system in the Czech republic, and the
software doesn't work. Until I can set up a Czech version of Windows
and do some debugging I can't be certain but on the face of it looking
at the failure messages the software is displaying, it looks as though
either the CRLF end of line terminations are not being sent or
received, or the command string being sent is becoming mal-formed on
its way out through SerialPort.

Do any of you have any ideas? Have any of you experience with this
kind of situation?

All help gratefuly received.

Regards
~A
 
K

Kornél Pál

Hi,

If you really use ASCII (that is a 7-bit encoding) you only have to
worry about ToString() and Parse() methods. You should use
CultureInfo.InvariantCulture.

Anyway, here is what you may be interested in:
Encoding.Default
Thread.CurrentThread.CurrentCulture

You can set the latter in .NET code on a per thread basis (new threads
inherit form the creator).

Encoding.Default can only be modified on a per-system basis in control
panel:
Regional and Language Options
Language setting for non-Unicode programs

Despite the description this is actually a code page rather than a
language and has nothing to do with the system default locale (but it's
wise to keep in sync the two of them).

For debugging purposes set both the localse (formats) and the code page
(language) to Czech.

Unless you have MUI version of Windows you will still have the texts in
English so you will be able to change it back to English simply.

Kornél
 
A

Andrew

Hi,

If you really use ASCII (that is a 7-bit encoding) you only have to
worry about ToString() and Parse() methods. You should use
CultureInfo.InvariantCulture.

Anyway, here is what you may be interested in:
Encoding.Default
Thread.CurrentThread.CurrentCulture

You can set the latter in .NET code on a per thread basis (new threads
inherit form the creator).

Encoding.Default can only be modified on a per-system basis in control
panel:
Regional and Language Options
Language setting for non-Unicode programs

Despite the description this is actually a code page rather than a
language and has nothing to do with the system default locale (but it's
wise to keep in sync the two of them).

For debugging purposes set both the localse (formats) and the code page
(language) to Czech.

Unless you have MUI version of Windows you will still have the texts in
English so you will be able to change it back to English simply.

Kornél











- Show quoted text -

Hi Kornél

CultureInfo.InvariantCulture sorted the problem. Thanks for the help
~A
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top