Skip to main content
September 1, 2010
Question

FileReference.save does not work well with Chinese word

  • September 1, 2010
  • 1 reply
  • 1428 views

I have one application that needs saving some text to local file folder, the text may include chinese words, and i found Flex's FileReference.save can do the job. But the problem is when i opened the saved file with Wordpad, the chinese words does not show correctly, but Notepad can show the text correctly.

From Adobe's help document about FileReference.save, "If the value is a String, it is saved as a UTF-8 text file."

So i think it is probably an encoding problem, but why Wordpad and Notepad behaviors differently, did they use different encoding? what encoding did they use ? ANSI?

Does anyone has similar problem and can give some explanation ?

Thanks a lot.

This topic has been closed for replies.

1 reply

Participant
January 12, 2011

you should use ByteArray to  export your file

here is the sample code

var f:FileReference = new FileReference();

var _txtByte :ByteArray = new ByteArray();

var str:String ="......";

var _txtByte :ByteArray = new ByteArray();

_txtByte.writeMultiByte(str,"cn-big5");  //for traditional chinese

f.save(_txtByte, "test.csv");

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/charset-codes.html  ==> charset reference