• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1004
  • Last Modified:

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
0
irmsystems
Asked:
irmsystems
  • 3
  • 2
1 Solution
 
prakash_prkCommented:
try this methods.

System.Text.ASCIIEncoding.ASCII.GetBytes() //to get the bytes
System.Text.ASCIIEncoding.ASCII.GetString() //to get the string
0
 
irmsystemsAuthor Commented:
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
0
 
irmsystemsAuthor Commented:
Hi,

I got it figured out.  

Byte[] encodedBytes = System.Text.Encoding.Default.GetBytes(sString);
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
prakash_prkCommented:
thats nice.
0
 
prakash_prkCommented:
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
0
 
GranModCommented:
Closed, 100 points refunded.

GranMod
The Experts Exchange
Community Support Moderator of all Ages
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now