[swx] Foreign characters with swx

Fabrício Seger Kolling dulldusk at gmail.com
Wed Dec 12 03:02:27 PST 2007


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
>> http://osflash.org/mailman/listinfo/swx_osflash.org
>>   
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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/a124bd02/attachment.html 


More information about the swx mailing list