Asian Characters in Flash

At my current job, we have a website with many Asian members who, of course, post content in Asian double-byte characters. We’ve jumped through a few hurtles to make sure that our site correctly stores and displays these characters: making sure data is UTF-8 encoded, making sure that we run our text through a combination of escape(), unescape(), encodeURIComponent() and decodeURIComponent() depending on whether we’re saving or retrieving data. For the most part, our site has no problem. Then we had to go and add Flash into the mix, and things got a little weird.

We’ve embedded stylized decorative fonts in our .swf files and allow our users to choose a particular font to use when viewing text. Customization is a good thing after all. The user’s font choice is dynamically loaded at runtime (cos AS 3.0 is cool like that) which keeps our file size very small. Now this works perfectly for Western characters, even special characters with umlauts and accent marks but fails miserably for Asian characters, they simply do not appear. You can have a text string with mixed Western and Asian characters and only the Western characters will display.

I’ve been thinking about this problem on and off for about a week without any breakthroughs, even dusted off the old forum logins and asked for advice. Yesturday, though, I think I figured it out.

Try this. Make a new .fla and throw a half dozen or so dynamic textfields on stage. Go grab some Asian characters off the web and paste them into your textfields. (It helps to have the Asian character packs installed on your OS, btw.) Now change the font of each text field to something different. Now look closely. I’m willing to bet that the Asian characters look identical regardless of the font you’ve chosen. Whether you have a serif or sans-serif font, a traditional or decorative font, the Asian characters probably all look the same.

This little experiment suggest to me that the Asian characters are actually being displayed via a system font as opposed to the font of your choice. Which makes some sense since you probably needed to update your OS with an Asian character pack inorder to see the characters at all. I image that if Arial, Garamond, Times, Futura (pick your favorite font) actually did contain over 40,000 traditional Chinese, Japanese, and Korean characters the file size would be significantly larger than a few kb.

I’d love to find someone who can confirm this little theory. It perfectly explains why Western characters show up in textfields set to use an embedded font but Asian characters do not.

Be Sociable, Share!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">