tags:

views:

42

answers:

3

I'm migrating an application from VB6 to .NET and in VB6 i have a a call to this method: CharToOemA. I don't understand what it does and how I can reproduce this functionality. The line in VB6 is like this: Call CharToOemA(Text, Text), where Text is a string.

Is there an equivalent in .NET for CharToOemA from VB6? If there isn't how can i implement this in .NET?

A: 

Look at the Encoding class. It defines several different character encodings (such as UTF-8 or ASCII) and can be used to Convert between them.

Oded
A: 

Depending on what you are trying to achieve you might not have to use it at all. Strings in .NET are always in Unicode encoding.

Jonas Elfström
+1  A: 

CharToOem is a Windows API call, not a native part of VB6. I'm guessing the VB6 is using it to convert a native VB6 string into an OEM string. OEM is the character set usually used by console programs.

I don't know why your VB6 code wants to create an OEM string. That would be the first thing I would investigate - what is the VB6 trying to achieve? There may be an entirely different way to achieve the goal in .Net.

You may be able to replace CharToOem with the .Net Convert, although you might have to specify exactly which OEM character set you want to use (OEM United States, OEM Multilingual Latin I...).

MarkJ