Modify

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#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 Changed 7 years ago by TicketCleanup

  • Version 3.3.9.4 deleted

Automatic ticket cleanup.

comment:2 Changed 7 years ago by guinness

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

comment:3 Changed 7 years ago by jchd

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

comment:4 Changed 7 years ago by guinness

  • Resolution set to Rejected
  • Status changed from new to closed

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 Changed 7 years ago by anonymous

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.

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.