Flash text encoding Problem solving scheme

Source: Internet
Author: User
Tags variable
Coding | solving | problems

When we are going to do a message based on flash or blog, it is inevitable for the Chinese character input and output to move a brain, here I sum up a little experience to do some reference.

programme one: most easily implemented and most effective

Whether you use Loadvars or loadvariables to submit information to the server, you first code with escape, the server does not do any other processing, write directly to the database, whether in XML or loadvariables when reading data (application/ x-www-form-urlencoded) to flash data can be transmitted, but in Flash to use unescape decoding and then display. This way can support the vast majority of text display (China, Japan, Korea ...). )。

Disadvantages: Occupy more database space and cup time, relatively slow.

Programme II: Common Methods

Use Flash Player 6, AS1 to publish SwF.

First-line Input system.usecodepage = True in the first frame of the home view so that we can see the familiar Chinese characters in the database instead of garbled characters.

Disadvantages: Large dependencies, depending on the operating system that the user is using, are not suitable for all users.

Scenario Three: A method between the above two

Publish SWF with Flash Player 7, AS2 (AS1).

Use Loadvars to submit information to the server and output information from the server side with XML. In this way you will see the UTF-8 code in the database, unknown so, but in the flash end can normally be displayed.

Deficiencies: sometimes not normal to submit and display information (submission of information, but the database is not, the database, but not the show), that is, unstable.

Solution: After the study found that the character conflict (but how the conflict I can not get the answer: ().
We can do this by adding EOF to each variable to be submitted, so that the server can distinguish the variables exactly, otherwise they run everywhere (such as the value of the variable in the title of the database field, but run to the content). When shown in Flash, you can remove the EOF and show it again.

Also, this approach is sensitive to character "<>" (there may be other, temporarily not found) and should be replaced if there is something in the content, otherwise the information cannot be submitted.

It is necessary to mention that, when importing data from text files (TXT, XML, etc.), the text file is best stored in UTF-8 code (you can also use ANSI, and then add "System.usecodepage = true" in Flash), but as far as I know only the Flash Player 6 AS1 and below are valid).

Loop play on OK:)



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.