Answered by:
Encoding of string

Question
-
Hi,
I'm just finalizing a custom workflow and doing some final test - and then I run into a problem with danish characters; using the UpdateResourceActivity I pass a string as a value, but I end up with a strange result in the portal -
Result: Søren Granfeldt
Expected result: Søren Granfeldt
The code for updating is plain and simple:
OutputValue = this.ResolvedExpression;
UpdateTargetResourceActivity.ActorId = containingWorkflow.ActorId;
UpdateTargetResourceActivity.ResourceId = containingWorkflow.TargetId;
UpdateTargetResourceActivity.UpdateParameters = new UpdateRequestParameter[]
{
new UpdateRequestParameter(Destination, UpdateMode.Modify, OutputValue)
};This has to do with strings in C# / .NET being Unicode/UTF-16 by default and I've tried converting to UTF-8 with no luck; is this just a visual problem or have anyone hit this problem as well?
Regards (and feeling stupid :-))
Soren
Regards, Soren Granfeldt --------------- http://granfeldt.blogspot.comSaturday, October 16, 2010 10:44 PM
Answers
-
You may want to try this ... it caters for the HTML encode/decode issue, but I don't know how it goes with the danish character set (but this should be a good start):
OutputValue = System.Web.HttpUtility.HtmlDecode(this.ResolvedExpression);
Bob Bradley, www.unifysolutions.net (FIMBob?)- Marked as answer by Søren Granfeldt Monday, November 15, 2010 10:03 AM
Tuesday, November 9, 2010 12:49 AM -
You may want to try this ... it caters for the HTML encode/decode issue, but I don't know how it goes with the danish character set (but this should be a good start):
OutputValue = System.Web.HttpUtility.HtmlDecode(this.ResolvedExpression);
Bob Bradley, www.unifysolutions.net (FIMBob?)
I just tested this in a PowerShell window and it worked fine. The ResolveGrammarActivity which I'm inferring the OP is using does have this annoying behavior. I just have a post-activity that runs the output through the above method.
My Book - Active Directory, 4th Edition
My Blog - www.briandesmond.com- Marked as answer by Søren Granfeldt Monday, November 15, 2010 10:03 AM
Tuesday, November 9, 2010 1:53 AM
All replies
-
No one?
Regards, Soren Granfeldt
http://granfeldt.blogspot.comMonday, November 8, 2010 11:41 AM -
You may want to try this ... it caters for the HTML encode/decode issue, but I don't know how it goes with the danish character set (but this should be a good start):
OutputValue = System.Web.HttpUtility.HtmlDecode(this.ResolvedExpression);
Bob Bradley, www.unifysolutions.net (FIMBob?)- Marked as answer by Søren Granfeldt Monday, November 15, 2010 10:03 AM
Tuesday, November 9, 2010 12:49 AM -
You may want to try this ... it caters for the HTML encode/decode issue, but I don't know how it goes with the danish character set (but this should be a good start):
OutputValue = System.Web.HttpUtility.HtmlDecode(this.ResolvedExpression);
Bob Bradley, www.unifysolutions.net (FIMBob?)
I just tested this in a PowerShell window and it worked fine. The ResolveGrammarActivity which I'm inferring the OP is using does have this annoying behavior. I just have a post-activity that runs the output through the above method.
My Book - Active Directory, 4th Edition
My Blog - www.briandesmond.com- Marked as answer by Søren Granfeldt Monday, November 15, 2010 10:03 AM
Tuesday, November 9, 2010 1:53 AM -
ResolveGrammarActivity is not supported
http://msdn.microsoft.com/en-us/library/microsoft.resourcemanagement.workflow.activities.resolvegrammaractivity.aspx
The FIM Password Reset Blog http://blogs.technet.com/aho/Tuesday, November 9, 2010 4:31 AM -
Hi, guys
Finally got around to testing this and indeed it does seem to have something with HTML en-/decoding to do, so thanks very much for those inputs. With this decoding fix, I was able to finish up one of my necessary workflows. My code lines now says -
// convert to proper casing OutputValue = System.Web.HttpUtility.HtmlDecode(this.ResolvedExpression); OutputValue = ProperCase(OutputValue);
If you're interested, a test copy will be available; see http://granfeldt.blogspot.com/2010/10/custom-workflow-for-propercasing.html
Thanks to everyone for chipping in...
Regards, Soren Granfeldt
http://granfeldt.blogspot.com- Edited by Søren Granfeldt Monday, November 15, 2010 10:05 AM Add code block
Monday, November 15, 2010 10:03 AM -
Anthony - I know the post above says that this activity is not supported, but I'm not sure this has always been the case - otherwise there wouldn't be a heap of custom activities written by the likes of MCS over the past year or so which make extensive use of this!!! I believe that either this activity needs to become supported asap ... either that or someone publishes a method for us all to use that is just as good if not better so that we can migrate away from using it (which represents a LOT of work in some sites I know). Can anyone explain to us WHY this activity isn't supported, and why there are so many activities that seem to fall into this category? I find it very puzzling that an API exposes methods like this and then tells people not to use them ... a bit like giving your daughter the keys to the car while you're out and asking her not to drive :)
Bob Bradley, www.unifysolutions.net (FIMBob?)Monday, November 15, 2010 10:56 PM -
Good points, Bob; even though not supported, I think it's almost imposiible to do a good WF without using this. I, too, would be very interested to know why this is not supported - could it be just a documentation error/mistake?
BTW: My daughter is only 15 months old - and there is no chance she's gonna my car keys the next couple of years :-) == NOT supported in current DAD version...
Regards,
Soren
Regards, Soren Granfeldt
http://granfeldt.blogspot.comMonday, November 15, 2010 11:03 PM -
That was actually my first thought too (that it was a doco error). I am trying very hard to keep a lid on my frustration, and trying not to get too bitter and twisted over this.
Bob Bradley, www.unifysolutions.net (FIMBob?)Monday, November 15, 2010 11:06 PM -
And you're right ... I need my activities to be generic, which means if they are to be maintainable they need to support parameters that will resolve our quirky xPath statements. Surely if this ISN'T supported people will start to come up with their own alternatives (i.e. their own "query dialects"), and how unsupportable would that be???
Bob Bradley, www.unifysolutions.net (FIMBob?)Monday, November 15, 2010 11:09 PM -
I am not in a position to comment that. I have already forward this thread to one of the PMs and ask him to take a look at this.
The FIM Password Reset Blog http://blogs.technet.com/aho/Monday, November 15, 2010 11:12 PM -
Thanks Anthony - will wait with eager anticipation :)
Bob Bradley, www.unifysolutions.net (FIMBob?)Monday, November 15, 2010 11:17 PM