469,325 Members | 1,552 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,325 developers. It's quick & easy.

parsing the output using string.split and current locale..

Hello,

I have a legacy unmanaged application that returns property=value
pairs separated by chr(252)and I am trying to parse this output from
C# using string.split method.

This works fine as long as the default locale is en-US. However, the
moment, I change it to say Greek/Portuguese, the parsing logic goofs
up. I don't have access to the source code of legacy application to
make changes.

Is there any way, by which, I can change the parsing logic such that
it works irrespective of the locale?

Thanks.
-Prasad
Nov 17 '05 #1
1 1673


p1=v1p2=v2p3=v3
p1=v1p2=v2p3=v3

Shouldn't be necessary to change anything in the legacy application, but
you need to change the character to split with. I suspect chr(252) is
in USA and in Greece, both with byte value 252, but with different
encoding.

You could try to grab the character for byte value 252 using
Encoding.Default which is the default encoding used for whatever language
the OS is set to use.

char splitCharacter = Encoding.Default.GetString(new byte[]{252})[0];
--
Happy Coding!
Morten Wennevik [C# MVP]
Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Gerrit Holl | last post: by
6 posts views Thread by Tuang | last post: by
9 posts views Thread by Thomas W | last post: by
11 posts views Thread by Roger Leigh | last post: by
6 posts views Thread by Tim N. van der Leeuw | last post: by
1 post views Thread by Malcolm Greene | last post: by
8 posts views Thread by =?Utf-8?B?TTFpUw==?= | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.