[swx] Foreign characters with swx
Rune Høck Møller
mail at runehock.dk
Wed Dec 12 05:47:10 PST 2007
I can give it a try, but I actually got it to work without
Fabrícion's code.
I just wrote this in my function php script.
where I before had:
{
return "$text";
}
I just wrote utf8_encode before $text:
{
return utf8_encode($text);
}
<?
The php file looks like this:
class Calendar
{
function getid($idflash)
{
$db_name = "db_name";
$connection = @mysql_connect("db_url", "db_user",
"db_pass");
mysql_select_db($db_name, $connection);
$query = "SELECT * FROM Calendar WHERE id =
'$idflash'";
$text = mysql_query($query);
$result=mysql_query($query);
while(list($id,$text)= mysql_fetch_row($result))
{
return utf8_encode($text);
}
}
}
?>
I dont know if this is the right way to do it, but it works and I
personally think that it is easier and faster to write!
I hope that this subject didn't got to far from the dealing with swx.
Because it is also an actionscript issue.
Thanks,
Rune
Den 12/12/2007 kl. 13.32 skrev Aral Balkan:
> 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> 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
>
>
> 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
>>
>
> _______________________________________________
> 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/3a5de51e/attachment.html
More information about the swx
mailing list