[swx] Foreign characters with swx
Fabrício Seger Kolling
dulldusk at gmail.com
Wed Dec 12 11:16:06 PST 2007
I agree with Nederflash, data manipulation should be done at client side
always that its possible.
Furthermore, if your planning to return much data, using a recursive
utf8_encode like i do will cause a major load on the server.
But it's very helpful when you want to return complex data structures.
Ex. an array of news, each having title, text and an array of images
with legend.
If a system or website doesn't need foreign characters, i would simply
comment that function call.
But as a matter of fact, Flash expects to receive data on UTF-8 format.
http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00000726.html#91109
"/Flash Player versions 6 and 7 support text or external files in
the 8-bit Unicode format UTF-8, and in the 16-bit Unicode formats
UTF-16 BE (Big Endian) and UTF-16 LE (Little Endian)./"
http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00000752.html#91141
/"You should save the external file in UTF-8 (recommended),
UTF-16BE, or UTF-16LE format, using an application that supports the
format."/
So, in this particular case, i think its the server job to provide the
data in a way flash can understand.
The System.useCodepage setting doesn't have any effect on data loaded
from SWX, only on external plain text and XML files.
However, System.useCodepage does affect all foreign characters sent to
the server.
If it is set to false (default value) foreign characters will be sent to
the server using Unicode.
Therefor i modified this line on swx.php (near line 286)
> $dataAsPhp = stripslashes(utf8_decode($data));
If it is set to true, foreign characters will be sent to the server
using the local system code page.
This will dispense the use of utf8_decode on single language systems.
But on a multilanguage environment, its unacceptable.
Resuming:
Flash to PHP
System.useCodepage = false;
utf8_decode received data
PHP to Flash
utf8_encode data before generating SWX output
Anyhow, please run your own tests and correct me if i said anything wrong.
Cheers
Fabrício Seger Kolling
<mailto:fabricio at esmeril.com.br>
Nederflash (Folkert Hielema) wrote:
> Isn't this depending on the charSet settings ? The current on the public
> gateway doesn't like foreign characters. But i see this setting in
> amf.php so i don't know how this affects swx.php but it should be the
> same i hope/guess. Must do some test to know for sure.
>
> Furtheron, i for one don't like data to be 'adjusted' on Server side. So
> the code used to fix the linebreaks is on client side (didn't notice any
> trouble sofar). But we should reconsider manipulating data, before it
> goes to the client.
>
> my two cents,
>
> Folkert
> Aral Balkan wrote:
>
>> Can some people affected by this issue please test Fabrício's code.
>>
>> It would be great if we could get some test cases for this.
>>
>> And I can include it in the next release once we're sure it's stable.
>>
>> Thanks,
>> Aral
>>
>> On Dec 12, 2007 11:02 AM, Fabrício Seger Kolling <dulldusk at gmail.com
>> <mailto:dulldusk at gmail.com>> wrote:
>>
>> To get foreign characters working I utf8_encode all strings on the
>> function call result, before generating the swf file.
>> Here's the function that I added to swxCompiler.php
>>
>> function fixData($data){
>> // Assoc Array to Object
>> // UTF8 Encode Strings
>> // Fix Line Breaks
>> if (is_array($data)) {
>> reset($data);
>> $k = key($data);
>> if (strlen($k)==0){
>> return $data;
>> } elseif ($k !== intval($k)) {
>> $data = (object)$data;
>> return $this->fixData($data);
>> } else {
>> $d = Array();
>> foreach ($data as $key => $val) {
>> $d[$key] = $this->fixData($val);
>> }
>> return $d;
>> }
>> } elseif (is_object($data)) {
>> $d = new stdClass();
>> foreach ($data as $key => $val) {
>> $d->{$key} = $this->fixData($val);
>> }
>> return $d;
>> } elseif (is_string($data)) {
>> return utf8_encode($this->fixLineBreaks($data));
>> } else {
>> return $data;
>> }
>> }
>>
>> function fixLineBreaks($str){
>> // Prevent CRLF from resulting 2 line breaks on Flash multiline
>> TextFields
>> // CRLF -> LF
>> // CR -> LF
>> if (strpos($str, chr(13)) !== false) {
>> $str = str_replace(chr(13), chr(10),
>> str_replace(chr(13).chr(10), chr(10), $str));
>> }
>> return $str;
>> }
>>
>> Fabrício Seger Kolling
>>
>> <mailto:fabricio at esmeril.com.br>
>> ben wrote:
>>
>>> That sounds more like a Flash issue than a swx issue...
>>>
>>> Some pointers
>>>
>>> I don't know how you're "showing" the characters in your flash app
>>> (textfield?) but maybe the extended characters aren't embedded ?
>>>
>>> If you "trace" the value, does it display correctly in the output
>>> window?
>>>
>>> It's possible also that you might have to "encode" your string as
>>> unicode in php before sending it out for flash to recognise it.
>>>
>>> Might be more of an Actionscript forum question altogether though...
>>>
>>> Ben
>>>
>>> Rune Høck Møller wrote:
>>>
>>>> Hi All,
>>>>
>>>> I am having problem with showing foreign characters with swx.
>>>>
>>>> My setup:
>>>>
>>>> I get text into flash from a mysql with swx.
>>>>
>>>> I have embedded the specific characters needed ( danish
>>>> characters æøå ) in flash and tried with " System.useCodepage =
>>>> true; " but nothing works.
>>>>
>>>> I have also tested my php script in the browser and it returns
>>>> the characters just fine.
>>>>
>>>> My question is:
>>>>
>>>> Am I doing something wrong?
>>>>
>>>> Is the swx not build for foreign languages?
>>>>
>>>> Thanks in advance,
>>>>
>>>> Rune
>>>>
>>>> ------------------------------------------------------------------------
>>>>
>>>> _______________________________________________
>>>> swx mailing list
>>>> swx at osflash.org <mailto:swx at osflash.org>
>>>> http://osflash.org/mailman/listinfo/swx_osflash.org
>>>>
>>>>
>>> ------------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> swx mailing list
>>> swx at osflash.org <mailto:swx at osflash.org>
>>> http://osflash.org/mailman/listinfo/swx_osflash.org
>>>
>>>
>> _______________________________________________
>> swx mailing list
>> swx at osflash.org <mailto:swx at osflash.org>
>> http://osflash.org/mailman/listinfo/swx_osflash.org
>> <http://osflash.org/mailman/listinfo/swx_osflash.org>
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> swx mailing list
>> swx at osflash.org
>> http://osflash.org/mailman/listinfo/swx_osflash.org
>>
>>
>> ------------------------------------------------------------------------
>>
>> No virus found in this incoming message.
>> Checked by AVG Free Edition.
>> Version: 7.5.503 / Virus Database: 269.17.1/1181 - Release Date: 11-12-2007 17:05
>>
>
>
> _______________________________________________
> swx mailing list
> swx at osflash.org
> http://osflash.org/mailman/listinfo/swx_osflash.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://osflash.org/pipermail/swx_osflash.org/attachments/20071212/99f3ab71/attachment-0001.html
More information about the swx
mailing list