Link to home
Start Free TrialLog in
Avatar of irmsystems
irmsystems

asked on

Convert string to byte array using ANSI

Hi,

I have a string that was created using ANSI encoding (Created in Visual FoxPro) The string was encrypted using some math to replace the characters and when I convert the string into a char array in .NET i get different byte values. How can I convert a string into a byte array or char array using ANSI?

Thank you
Avatar of prakash_prk
prakash_prk
Flag of India image

try this methods.

System.Text.ASCIIEncoding.ASCII.GetBytes() //to get the bytes
System.Text.ASCIIEncoding.ASCII.GetString() //to get the string
Avatar of irmsystems
irmsystems

ASKER

Thanks I have tried that

Here is an example that doesn't work

My string that I need to get the bytes from:

string sTest = "ŠŒ™‹‘•“œœž";

The value of the S with the caron is 138 in FoxPro and in .NET it is 352

.NET is using UNICODE to get the byte value. I need to somehow use ANSI within .NET to get the value of 138 for the character.

Thanks
Hi,

I got it figured out.  

Byte[] encodedBytes = System.Text.Encoding.Default.GetBytes(sString);
thats nice.
dear netminder.

I think irmsystems get the exact solution from my suggesstion.
On his question he was not given the exact string / byte arry to check.
so that only I post some methods in the Ascii encoding clssas.

I dont want this kind of behavior from irmsystems

go ahead Netminder . i dont want the points


regards
prakash
ASKER CERTIFIED SOLUTION
Avatar of GranMod
GranMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial