How to return escaped characters from MathLink?

I'd like to return Greek symbols through MathLink from a C function. However, returning the usual escape sequence (such as \[Alpha]) does not seem to work. Here's a minimal example .tm file (myalpha.tm) which creates a function that should simply return \[Alpha] :

void myAlpha P(( ));

:Begin:
:Function:          myAlpha
:Pattern:           myAlpha[ ]
:Arguments:         { }
:ArgumentTypes:     { }
:ReturnType:        Manual
:End:

void myAlpha() { MLPutSymbol( stdlink, "\\[Alpha]" ); }
int main(int argc, char *argv[]) { return MLMain(argc, argv); }


To compile it (on OSX) I use :

/Applications/Mathematica.app/SystemFiles/Links/MathLink/DeveloperKit/MacOSX-x86-64/CompilerAdditions/mprep myalpha.tm -o myalphatm.c


And to run it I execute this little script :

link = Install["<fullpath>/myalpha"];
myAlpha[];
Print[%]


Inside a Mathematica notebook this produces some binary symbol, and if I run it with MathKernel from the commandline then I get :

$IterationLimit::itlim: Iteration limit of 4096 exceeded. Hold[Out[$Line - 1]]


My guess is that I haven't escaped everything correctly in the C string, but I'm not sure what the right escape sequence is. Since \ is the escape character in C I have escaped that, so the C-string reads "\\[Alpha]" and I've tried a variety of other options but to no avail.

-

I'm not an expert here, but one way to achieve what you want is to transfer UTF8 codes. I guess the assumption that you can simply transfer a string "\[Alpha]" as Symbol over MathLink and Mathematica interprets this for you, cannot be made. Therefore, the following is a different solution which works as expected (at least on my Linux here)
void myAlpha() {

This works on OSX as well but MLPutUTF8Symbol needs a pointer to an unsigned char, so an explicit cast before the string is necessary. I.e. MLPutUTF8Symbol( stdlink, (const unsigned char *) "\u03B1", 2);. –  Rasmus Apr 15 '14 at 14:28