c# - Using PostMessage to send Unicode characters -


i using postmessage send input flash object in application. works fine until try send unicode character. in example:

michael’s book

the apostrophe not that, not ascii 39, rather unicode u+2019. time sent across 1 character @ time, lost unicode value , lands raw characters making unicode

michael’s book

if copy , paste window moves fine, , if load text file window loads fine. receiving window able receive unicode, way sending must not correct. appreciated.

  private void sendkeystoform(string message)     {         (int = 0; < message.length; i++)         {             postmessage(hwnd, wm_char, (intptr)message[i], intptr.zero);         }     } 

per msdn documentation, send unicode, need use postmessagew.

it's same method signature, import name postmessagew , execute that.

update

as hans stated, better approach set charset of dllimport:

[dllimport("user32.dll", charset=charset.unicode, setlasterror=true)] private static extern bool postmessage(intptr hwnd, int msg, intptr wp, intptr lp); 

this should cause framework import postmessagew.

thanks lot hans!


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -