1

It has to work with a C program so it has to be a winapi c call

shawn
  • 4,063
  • 7
  • 37
  • 54

3 Answers3

8

That would be WideCharToMultiByte and MultiByteToWideChar.

Eran
  • 21,632
  • 6
  • 56
  • 89
  • Are there examples on how to use it? – shawn Sep 27 '11 at 11:44
  • 1
    @shawn, you can find some example in [this question](http://stackoverflow.com/questions/215963/how-do-you-properly-use-widechartomultibyte). Those function are very commonly used, so you'll have no problem finding other examples on the web. They both take about a million arguments, but for simple cases you can use the defaults. – Eran Sep 27 '11 at 12:00
3

All 128 ASCII characters convert to the unicode code point with the same value (see ASCII in unicode glossary). Conversion, in C (have no idea about the other tags in your question), is as easy as assignment: unicodevalue = asciivalue; or asciivalue = unicodevalue; though you probably want to make sure that unicodevalue in the last staetement represents an ASCII character before converting.

pmg
  • 106,608
  • 13
  • 126
  • 198
0

Here is a simple solution which comes along with CRT ; consider this if you are using Visual studio.

mbstowcs and wcstombs the links have sample C++ code too.

Madhu Nair
  • 142
  • 3