22 November 2008

Flex HTTPService - how to change character set of parameters

Adobe Flex Tipp: How to change character set of parameters submitted with HTTPService object's send() method.

By default, HTTPService send parameters as name/value pairs and they are converted to URL-encoded format using UTF-8 character set.

It is possible to use system character set by adding in application
System.useCodepage = true

public static function get useCodePage reference():

Additional information

You can get the Player to fall back on making a different character set guess by setting System.useCodepage=true. So do that before executing your http service, and then after the httpservice result comes back I'd recommend setting useCodepage back to false.

Matt Chotin


Why Flex change the CharacterEncoding of HTTPSer vice's result?

You can also try somewhere in your application setting System.useCodepage = true. Normally we only support UTF-8 character sets. If you set useCodepage to true it will attempt (and sometimes get right) using another character set.



It's possible that setting this for the life of the application will have negative consequences, you may need to narrow it down to set it to true before you send the HTTPService request and set it to false after the HTTPService returns.


flexcoders

useCodePage property can be used also in other cases:
escapeMultiByte () function
Returns an escaped copy of the input string encoded as either UTF-8 or system code page, depending on the value of System.useCodePage. Use of System.useCodePage allows legacy content encoded in local code pages to be accessed by the player, but only on systems using that legacy code page.

No comments: