> Is it possible to write a Unicode encoded text file with JSFL? Yes, absolutely. Except that there's no such thing as a 'Unicode encoded text file' - there are a number of different encodings all of which refer to Unicode mappings in different ways, the most common of which is probably UTF-8.
> If so how can I do it? Well, for starters here's a function that will translate a string into an array of UTF-8 values. To write it out as a text file, just convert each number to a character using String.fromCharCode. function getUTFArray(tString:String) { var tRes:Array = new Array(); var tCode:Number; for (var i = 0; i < tString.length; i++) { tCode = tString.charCodeAt(i); if (tCode < 128) { // One-byte (ASCII) range: 7 bits tRes.push(tCode); } else if (tCode < 0x800) { // Two-byte range: 11 bits var tTop = (tCode >> 6); // top 5 bits xxxxx var tCode1 = tTop + 192; // becomes 110xxxxx var tCode2 = tCode - (tTop << 6) + 128; // subtract off top bits to get 10yyyyyy tRes.push(tCode1); tRes.push(tCode2); } else if (tCode < 0x10000) { // Three-byte range: 16 bits var tTop = (tCode >> 12); // top 4 bits var tRem = tCode - (tTop << 12); var tMiddle = (tRem >> 6); // middle 6 bits var tBottom = tRem - (tMiddle << 6); var tCode1 = tTop + 224; // becomes 1110xxxx var tCode2 = tMiddle + 128; // becomes 10xxxxxx var tCode3 = tBottom + 128; // becomes 10xxxxxx tRes.push(tCode1); tRes.push(tCode2); tRes.push(tCode3); } else { // Four-byte range: 21 bits (fairly unlikely! Is this Klingon?) var tTop = (tCode >> 18); // top 3 bits var tRem = tCode - (tTop << 18); var tMiddleTop = (tRem >> 12); // next 6 bits tRem -= (tMiddleTop << 12); var tMiddleBottom = (tRem >> 6); // next 6 bits var tBottom = tRem - (tMiddleBottom << 6); var tCode1 = tTop + 240; // becomes 11110xxx var tCode2 = tMiddleTop + 128; // becomes 10xxxxxx var tCode3 = tMiddleBottom + 128; // becomes 10xxxxxx var tCode4 = tBottom + 128; // becomes 10xxxxxx tRes.push(tCode1); tRes.push(tCode2); tRes.push(tCode3); tRes.push(tCode4); } } return tRes; } HTH Danny _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com