how to pass unicode text from C# to Objective-C

i need pass a localized text from c# to native objective-c code,
i have the simple c# code:

    public class main : MonoBehaviour 
    	private static extern void _setText(string text);
    	void Start () {
    	    _setText("Привет Мир");

and objective-c:

extern "C" void _setText(const char* text)
    UIView* view = UnityGetGLView();
    UILabel* label = [[[UILabel alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    label.text = [NSString stringWithUTF8String:text];
    label.font = [UIFont fontWithName:@"Arial" size:50];
    [view addSubview:label];

with an english text it is work fine, but a localized text not convert to the expexted result.

also tried declare the c# signature method how

[DllImport("__Internal", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]


Have any ideas? Please help!

You need to specify the encoding in Objective C too. This should work on iOS:


class Foo
    static extern void SetText([MarshalAs(UnmanagedType.LPWStr)]string text, int textLength);

    void Bar()
        var text = "Привет Мир";
        SetText(text, text.Length);


extern "C" void SetText(const char16_t* text, int textLength)
    NSString* textAsNsString = [[NSString alloc] initWithBytes: (const void*)text
                                                        length: sizeof(char16_t) * textLength
                                                      encoding: NSUTF16LittleEndianStringEncoding];

    // Do something with textAsNsString