Flex + character getting replaced by blank when passed as application param
I am passing a string param into flex application as FlashVars
The param sometime contains special characters, everything shows fine except + sign which gets replaced by blank when it reaches flex.
Here is the scenario for eg.
I have a local variable in JS that gets some values and for this example it can be taken as following
<script language="JavaScript" type="text/javascript">
var testVar = "开发者_StackOverflow中文版some_test_string_that_contains_+_character";
</script>
Then to my Flex object AC_FL_RunContent I pass "FlashVars","test="+testVar
In the flex code on Init of application I have written
var testValue:String = application.parameters["testVar"].toString();
Alert.show(testValue);
Now this shows fine except the + character gets replaced by blank. It doesnt happens with other characters like /,@$-_ but the + character.
Any help regarding this will be greatly appreciated.
From Adobe's docs:
About flashVars properties encoding
The values of the flashVars properties must be URL encoded. The format of the string is a set of name-value pairs separated by an ampersand (&). You can escape special and nonprintable characters with a percent symbol (%) followed by a two-digit hexadecimal value. You can represent a single blank space using the plus sign (+).
Looking further down at one of the comments from matthew horn, it looks like you can use %2B
to pass the +
character.
精彩评论