david
david

Reputation: 292

C++ DLL special characters

I'm sending an user-generated string from my program into a C++ DLL function I'm making. It works fine, until I send a string like "åäö". My function looks something like this:

export void showMessage(char* str) {
    MessageBox(NULL, str, "DLL says", MB_OK);
}

When "åäö" is sent from the program, a message with "åäö" popups up. How do I convert it into "åäö"? What library is needed? I'm using Code::Blocks for the DLL.

Upvotes: 0

Views: 430

Answers (1)

Cloud
Cloud

Reputation: 19333

The characters you are using appear to be in the extended ASCII table (value greater than 127), and will depend on the code page you are using, which is a less than portable approach, since the system running your code needs to make environment changes outside of the program itself.

Instead of using MessageBox, use the Unicode enabled version, MessageBoxW, and look up the Unicode encodings for the characters you specified.

References


  1. Unicode Versions and ANSI Versions of Functions, Accessed 2014-06-06, <http://zone.ni.com/reference/en-XX/help/371361J-01/lvexcodeconcepts/unicode_ansi_version_functs/>
  2. ASCII Table Lookup, Accessed 2014-06-06, <http://www.theasciicode.com.ar/extended-ascii-code/capital-letter-a-ring-uppercase-ascii-code-143.html>
  3. Unicode Lookup, Accessed 2014-06-06, <http://unicodelookup.com/>

Upvotes: 2

Related Questions