Modify

#2325 closed Feature Request (Rejected)

_FilleWriteFromArray doesn't work with Unicode text

Reported by: BrewManNH Owned by:
Milestone: Component: AutoIt
Version: Severity: None
Keywords: Cc:

Description

In the File.au3 UDF _FileWriteFromArray, when passed a file name and not a handle, will open a file in OverWrite mode only. This means that if there's any Unicode characters in the array, they're written as question marks in the file.

$hFile = FileOpen($File, $FO_OVERWRITE)

I think that an easy fix/change for this would be to open it using 1 + 128 ($FO_OVERWRITE + $FO_UTF8) for UTF-8 with BOM or 1 + 256 ($FO_OVERWRITE + $FO_UTF8_NOBOM) to make it more compatable with Unicode.

Attachments (0)

Change History (5)

comment:1 by TicketCleanup, on Mar 14, 2013 at 9:00:02 PM

Version: 3.3.9.4

Automatic ticket cleanup.

comment:2 by guinness, on Mar 14, 2013 at 10:41:16 PM

Perhaps an additional parameter so the function is still backwards compatible?

comment:3 by jchd, on Mar 15, 2013 at 3:30:32 PM

A new parameter is actually the only solution because correct detection of the encoding of a text file is impossible in general.

comment:4 by guinness, on Mar 17, 2013 at 6:26:38 AM

Resolution: Rejected
Status: newclosed

The user can pass a file handle returned by FileOpen.

#include <FileConstants.au3>

Local $aArray['Example_1', 'Example_2', 'Example_3', 'Example_4']
Local Const $hFileOpen = FileOpen(@ScriptDir & '\Example.txt', $FO_OVERWRITE + $FO_UTF8_NOBOM)
_FileWriteFromArray($hFile, $aArray)
FileClose($hFileOpen)

comment:5 by anonymous, on Mar 17, 2013 at 9:29:06 PM

There's no backwards compatibility problem if you open it in UTF8 with no BOM, because standard ASCII and UTF8 are the same format, but standard ASCII won't save Unicode characters correctly.

As to passing it a file handle, I'm aware of that, because I mention it. The problem is that the UDF opens the file with no regard to the format of the text, whereas the simple change of the FileOpen command in the function doesn't change anything in regards to standard ASCII, and makes the UDF compatible with Unicode at the same time.

I think that this should be reconsidered for something that should have been done in the first place.

Modify Ticket

Action
as closed The ticket will remain with no owner.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.