Sign in to follow this  
Followers 0
silverstream

FileFind...() and FileCopy() vs filenames with macrons

8 posts in this topic

Hi

I've written a document synchroniser using AutoIt and it's working rather well except for one problem - a user created a file with the character a-macron (ā, or Alt-0257 so presumably ASCII character 0257) in the file name, which this synchroniser is supposed to copy, and AutoIt (or Windows?) doesn't like it.

It seems fileFindFirstFile() and fileFindNextFile() report a file "Te Reo Māori.doc" as "Te Reo Maori.doc" - changing the A-Macron (ASCII 0257) to the usual ASCII letter a (ASCII 0097).

When it comes to fileCopy()'s turn to copy this file, of course it doesn't find a file with the incorrectly returned name so it won't copy.

I suspect it may also fail on other unusual Unicode or extended characters in filenames.

Additionally, I tried to write some example code but am not having much luck with getting Chr(257) or Chr(0257) to work at all.

What should I be looking for to fix this? I'm stumped!

I'm using v3.2.2.0.

Thanks in advance,

Andrew

; Before running this you'll need to manually create a file at c:\ called "Māori.txt" with a-macron instead of a in the filename.
; Uploading a file with a macron in the name to the forum also failed.
; Chr(0257) isn't working so I can't create the file then search for it using AutoIt code.
; You may have to use Character Map to do this.


$handle = fileFindFirstFile("c:\*ori.txt")

MsgBox(0, "Test", "Found: " & fileFindNextFile($handle))

Share this post


Link to post
Share on other sites



I had this problem once with internet explorer, i was trying to download a website written in Chinese language , but windows kept saving using weird characters, but after i installed the correct fonts my problem was solved.

Try installing different kinds of fonts maybe it will work?

Share this post


Link to post
Share on other sites

Try installing different kinds of fonts maybe it will work?

Good grief that was one fast reply!!!

I'm able to paste (but not type or alt-0257) the ā into Firefox, (I can alt-0257 it in Notepad, Wordpad, Word, can't in Scite).

I'm not sure how installing fonts will get the macron from fileFind... to fileCopy successfully, but on my own machine (XPSP2) I've got everything for complex script, right-to-left, and east Asian languages installed (selected under Control Panel > Regional and Language Options > Languages. Even without these the macron is displayed correctly in Windows Explorer, yet I (and others) still get the above problem with it being converted to a regular a when an AutoIt script parses the name, causing fileCopy not to find the source file.

Thanks,

A

Share this post


Link to post
Share on other sites

*bump* Anyone else got any ideas?

Thanks in advance

Andrew

Share this post


Link to post
Share on other sites

in dos 8.3 the file Māori.txt is called mori~1.txt which would indicate that the ā char is just missing. maybe it will help you ?


> there are 10 types of people in the world, those who understand binary and those who don't.

Share this post


Link to post
Share on other sites

Coming back to this problem five years later (!), no trying to remove the ā from a file name and replacing it with nothing does not work.

Besides, there is no way to tell from the strings returned from FileFindNextFile() which "a" character names returned are supposed to be "a" or "ā", as there are often both.

The problem is still present using AutoIt 3.3.8.1.

Share this post


Link to post
Share on other sites

BTW, I also hit this problem when trying to FileCopy() using filenames returned from FileFindNextFile() when the files concerned originated on a Mac - some can have weird Unicode control characters in their filenames which, just like as above with ā, FileFindNextFile() doesn't return so FileCopy() can't find the source files.

Share this post


Link to post
Share on other sites

5 years of research, wow a long time indeed!

Anyway, search for WinAPIEx.au3 and look at _WinAPI_FileFindNextFile, maybe that will help you.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0