Skip to Content
0
Former Member
Mar 23, 2010 at 07:45 AM

String Parameters are not correctly forwarded to functions in UFL (C#)

36 Views

Hello,

I have a userdefined function library written in .NET/C#. Some of the methods in this lib have string parameters, which are forwarded with a wrong encoding:

When I pass "ABC_ÄÖÜ" from Crystal Reports, I receive "ABC_Ãu201EÃu2013Ãu0153" in my C# methods. To convert it back to the correct string, I have to do the following transformation:

s = Encoding.UTF8.GetString(Encoding.Default.GetBytes(s));

Example:

public int ShowMessage(string sMessage)

{

sMessage = Encoding.UTF8.GetString(Encoding.Default.GetBytes(sMessage)); // <-- Why is this neccessary?

MessageBox.Show(sMessage);

return 0;

}

Normally, crystal should pass the parameters in unicode and they should be transferred to my methods in the same way. It looks as if the unicode string from Crystal is somewhere interpreted as ANSI.

What can I do to get the string parameters correctly?

I'm using VS2005/.NET 2.0

Stephan

Edited by: swessel61 on Mar 23, 2010 8:47 AM