View Full Version : Special characters ... !?

10-04-2005, 12:00 AM
The danish language have these 3 special characters:

I have some problems when getting data from mySQL with PHP to Flash.
The characters doesn't display right.

"Gstebog" turns into "g[]ebog"
(well "[]" is more of a square - but i can't type that here)

I've tried embedding the characters in flash - but with no luck.
So i guess the error is within PHP.
mySQL has the option to choose danish menus on phpmyadmin - so i guess the problem doesn't come from mySQL.

Can anyone help me, please?!

10-04-2005, 04:05 AM
it has to do with the encoding of the data... your special characters is 16bit unicode....
just print or echo to the browser with php the characters. it you can see it then it's not php's problem..... i think you might have to send http header info with your data.. i remember briefly seeing this topic... you'll have to do some googling.
good searching.

10-04-2005, 06:55 AM
You should encode the characters as HTML entities and then load them as HTML. If that doesn't work, first go over the HTML in AS and replace the entities with the appropriate character. I've used a combination of both approaches to get special characters to work in one of my projects.

10-04-2005, 08:03 AM

Strange though....

Just running the php-code in browser (http://alsvik.dk/blog.php) returns the correct characters :confused:

So i guess the problem is inside flash. But shouldn't i be able to just embed the characters?

- but that doesn't work :mad:

10-04-2005, 09:18 AM
Let me sum up, what's going on:

In my movie, i get data from mySQL via PHP, to two different textfields:

AS in movie:

//function to load external data using the loadVars() object
//l=name of loadVars object
//n=name of text field
//t=trigger to decide whether to show all entries or just one.
//e= entry number to display (number)
//f=file to load from (string)
function lv(l, n, t, e, f) {
sb.setSize(null, 200);
sb2.setSize(null, 50);
//create a new loadVars object if one doesn't already exist if it does, use it
if (l == undefined) {
l = new LoadVars();
l.onLoad = function() {
var i;
//clear out any text that might already be there
n.htmlText = "";
//to show a single entry at a time we use the following code
if (t == undefined) {
n.htmlText += "<b>"+this["title"+e]+"</b><br>"+this["date"+e]+"<br><br>";
n.htmlText += this["entry"+e];
} else {
//cycle through and show all entries
for (i=0; i<this.n; i++) {
n.htmlText += "<u><a href='asfunction:_root.loadArc,"+this["id"+i]+"'>"+this["title"+i]+"</a></u><br>";
function loadArc(passed) {
arcNum = passed-1;
lv(blog_lv, entries_txt, undefined, arcNum, "blog.php");
//for the large entry textfield
lv(blog_lv, entries_txt, undefined, 0, "blog.php");
//for the archives text field
lv(archive_lv, archive_txt, "cycle", null, "blog.php");

// createClassObject like any other component. Name it vSB.
createClassObject(mx.controls.UIScrollBar, "SB", 10);
// set the target text field
// size it to match the text field
SB.setSize(16, entries_txt._height);
// move it next to the text field
SB.move(entries_txt._x + entries_txt._width, entries_txt._y);

// createClassObject like any other component. Name it vSB.
createClassObject(mx.controls.UIScrollBar, "SB2", 11);
// set the target text field
// size it to match the text field
SB2.setSize(16, archive_txt._height);
// move it next to the text field
SB2.move(archive_txt._x + archive_txt._width, archive_txt._y);

with php-code:

mysql_pconnect ("localhost", "username", "password");

mysql_select_db ("alsvik_dk");
$qResult = mysql_query ("SELECT * FROM blog_entries ORDER BY id DESC");

$nRows = mysql_num_rows($qResult);
$rString ="&n=".$nRows;

for ($i=0; $i< $nRows; $i++){
$row = mysql_fetch_array($qResult);
$rString .="&id".$i."=".$row['id']."&"."&title".$i."=".$row['title']."&"."&date".$i."=".$row['date']."&"."&entry".$i."=".$row['entry']."&";
echo $rString."&";


When entering the url to the php in IE, i get this:
"&n=3&id0=3&&title0=Alsvik.dk Gstebog&&date0=2005-10-04&&entry0=Gstebogen virker nu - og kan ogs benyttes om kontaktform, da indtastninger automatisk sendes til bde afsender og modtager :o)&&id1=2&&title1=Mailserver&&date1=2005-10-03&&entry1=Lidt detaljer om adgang til mails: POP3: pop.alsvik.dk SMTP: customer-smtp.b-one.net Der krves login til bde pop3 og smtp. Webmail kan benyttes fra b-one.net&&id2=1&&title2=Ny blog p alsvik.dk&&date2=2005-10-01&&entry2=S er alsvik.dk igen i luften :o) Alsvik.dk er flyttet p hotel - og nogle services er fjernet: Farvel til FTP, RA, Filservice & WAP Mailsystemet er krende igen!&& "

- as you can see, with the correct special characters: / .

I don't get it. What's wrong?!

Just noticed that when using these signs inthe database, everything shows up correct in flash:
æ =
ø =
å =
Æ =
Ø =
Å =

But that are som pretty weird signs, right?
And it should be possible fix this, instead of goring around

10-04-2005, 10:41 AM
The difference is that the url contains characters in a specific code page, while those other character codes you have are the unicode equivalents (at least, that's what I think is happening). You need to turn them into html entities with the htmlentities function in php.

10-04-2005, 10:47 AM
Please help jsebrech!

Don't know how to do that?
Is it easy, or do i have to modify the entire code?

Funny thing is that i discovered it using a guestbook. When i type in the in the flash-guestbook, the funny characters (æ=, ø=, å =, Æ) turns up inside the database ...

So somehov it isn't that bad. I just need to create a falsh movies that allows me to enter the blog-entries in flash, instead of directly into the database :(

10-05-2005, 08:21 AM
You surround the string you know contains international characters with htmlentities(). That will turn characters like into &egrave;. Then you can on the flash side replace that with the right character. I have to admit I'm not hero when it comes to international characters. I just got it to work that way. In my case I replaced it with the unicode, which for the character of is \u00E8

10-06-2005, 12:35 AM
here ya go.. urlencoding

10-14-2005, 08:55 AM
I'm having a similar problem. Im using php to write an xml file from mysql. PHP writes the file correctly but flash cant read the xml correctly. Instead of spanish characters such as , , , , , etc.. flash places that same undefined square character that youre getting.

I've gotten flash to, at least, read the whole xml file by adding this to my php script:


where $xml_output is the string to replace characters in. The php str_replace() function changes the special characters to HTML.

Now the problem i have is that the flash textfield doesnt convert the html &aacute; to .

any help is apprciated

10-14-2005, 09:49 AM
well i found a fix to my problem with just one line of php code:


It seems that PHP either mysql or php encode data in a different format other than the one Flash uses by default: UTF-8. So just have php encode the the string in UTF-8 and it is compatible with flash...

10-14-2005, 09:37 PM
again, it's the encoding...
your xml file format has to be saved or written as unicode text (UTF-16)...

sorry, not sure how that is done.

10-18-2005, 02:04 PM
Since i don't have many international guests at my site, i've just used the "system.use.codepage = true;"

This doesn't work with Flash 8 pro. So i published in Flash 7 :eek:

11-04-2005, 09:40 AM
You might go looking for repair pst (http://www.oemailrecovery.com/pst-repair.html) and email repair (http://www.mail-repair.com/email-repair.html). I have been using it without problem since it came out.

11-04-2005, 11:13 AM
PHP will use the default character set as configured in your php.ini. This is probably latin1, the default for western-european languages (english, french, spanish, german, ...). Flash however uses UTF-8 by default, which matches latin1 for the first 128 characters, but no longer does for other characters (special characters). When you utf8_encode you convert from latin1 to utf8. So, utf8_encode is pretty much a workable solution, unless at some point you're going to run it on a webserver that doesn't use latin1 as its php codepage.

11-21-2005, 03:55 PM
As far as rendering the characters in flash goes (since it doenst recognise the escaped HTML), I ran into the same problem with the and &pound; I decided to solve the problem by manually converting &pound; back to in flash. I noticed, however, that my replace function, which uses String.indexOf, wouldnt find &pound;. In the end, I got it to work by searching for "&amp;pound;" rather than "&pound;"

This seems like strange behavior though doenst it? The String object shouldnt have an inherant connection to HTML syntax.

01-16-2006, 02:29 PM
I just spent hours with a tricky problem, and I believe I was not the first or the last one to sweat on this one, so let's share the solution ;)

I have a form in Flash, and want it to send an email right? First, all the fields which can content special characters (, , , , , , , , etc...) have to be url encoded in Flash :
content_email = escape(content_email);

Then, I pass it to PHP, using a classic "POST".
In PHP I grab it simply like this:
$content_email = $_POST['content_email'];

So far so good, you probably got here... but... then, what you get in your email text is urlencoded in a weird gravy way! :D I found the way to decode that (still in PHP) :
$contentM = utf8_encode($content_email);
$contentX = rawurldecode($contentM);
$contentE = utf8_decode($contentX);
and finaly:
mail($to, $subject, $contentE, $mailheaders);

Don't ask me why though:eek: I think I understand, but can't realy explain!

That's it. If you want more of my test PHP codes, just ask.:D

01-17-2006, 06:25 AM
Well ...

I never really figured out how to make this -thing work with Flash 8.
I just published in Flash 7 and added the "use system code page = true;" in the first frame of my flash-file

01-17-2006, 06:53 AM
I use quite a few falsh-php-mysql systems in my web design jobs, and maybe I can give you my humble opinion...
For instance, the data which is in mysql (if I look at it thru MySQl CC ou any other interface) looks urlencoded/utf8 of some sort. This, because all my data which is in there is introduced by typing in the Flash interface, and sent to the server.
What I mean here is, that whatever goes into the MySQL columns comes back into Flash as it was in the first place... All it needs is that both ways are similar. I am working a lot with 4 languages which have special cgharacters French, German, Spanish and Portuguese... and that's how I have been doing my things so far.
The problem I mentioned yesterday was that when you have to "go out" of this routine "coding/decoding", you get weird stuff. Like writing an email with special characters.

So, my question would be: are you typing the data with "" directly into MySQL? Or is it introduced with a Flash interface?...

Keep faith!

01-18-2006, 07:55 AM
I enter the data in flash and POST it through a PHP, with no encoding.
The data in MySQL looks exactly like the data i posted!
This is the code that fixed it for me:

system.useCodepage = true;

01-18-2006, 09:13 AM
I enter the data in flash and POST it through a PHP, with no encoding.
The data in MySQL looks exactly like the data i posted!
This is the code that fixed it for me:

system.useCodepage = true;

You always use an encoding. When you use no encoding, you're using the default encoding. The default encoding on windows (both server and client) is usually latin1. Flash's native encoding is UTF8. Setting system.usecodepage makes it use the system (default windows) encoding, which is, as I said, probably latin1. Because the encodings now match, things "just work".

You'll still get into problems if a russian or chinese user tries to use your application. They do not use latin1 as system codepage.

01-18-2006, 11:27 AM
I did another job a few weeks ago, and had some trouble with
system.useCodepage = true;
I know there is a Flash version difference, can't remember which though :-)

I am producing all the time, and generaly if a solution works fine, and looks ok, that's the one! There is also probably different solutions possible, some more suitable for specific function.
In ActionScript, I can see many ways of doing things!... If useCodepage works for you, that's just great :-)

Take care!