jlf Posted October 8, 2013 Share Posted October 8, 2013 Hi, I encounter some problem with Unicode characters in path. In the following lines, the $MyPath variable contains a directory name (full path name, including letter drive). When using _ArrayDisplay, the Unicode character is correctly displayed. So $MyPath variable is OK. But both ConsoleWrite command loose this Unicode char. Later, in the same code, when I try to access to a file inside such a directory, the file is not found (because the path has lost its Unicode char). _ArrayAdd($TotDir,$MyPath) _ArrayDisplay($TotDir) $TotDir[0] += 1 ConsoleWrite("$TotDir[1] = " & $TotDir[1] & @CRLF) ConsoleWrite("$MyPath = " & $MyPath & @CRLF) I saw that AutoIt supports Unicode, but I can't find relevant information for my case. If someone could help me, it would be great For info : AutoIt 3.3.9.4 under Seven x64. Thanks in advance Link to comment Share on other sites More sharing options...
orbs Posted October 9, 2013 Share Posted October 9, 2013 i could not reproduce your problem. however, off-hand i'd say use FileGetLongName on the path and see what you get. next, please provide 3 screenshots: the path as displayed by 1) file manager, 2) _ArrayDisplay , and 3) ConsoleWrite Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
Solution czardas Posted October 9, 2013 Solution Share Posted October 9, 2013 (edited) If the characters display in the array, they will not disappear unless you modify the array contents. If you include the file name directly in your code, there is a chance it will be corrupted if not saved with the correct encoding. I tend to convert hard coded unicode to binary, but that's not meant to be a universal solution. I am wondering how you are trying to access the file. The following test shows that a file name which includes unicode can be opened without any problem. Place the script in the same folder as your file, copy the (unicode) file name to the clipboard and then run the script. ; Local $sName = ClipGet() Local $sPath = @ScriptDir & "\" & $sName Local $hFile = FileOpen($sPath) If $hFile = -1 Then Exit MsgBox(0, "Success", "This file has been opened :" & @CRLF & $sName) FileClose($hFile) Edited October 9, 2013 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
jlf Posted October 11, 2013 Author Share Posted October 11, 2013 Thnx czardas for your help. As you said, the Unicode characters were still in my variable, but the string was converted to regular ASCII with ConsoleWrite and through my DllCall (filename is sent to C code compiled to a DLL). This is a public GNU code which I have changed to receive a wchar_t instead of a char and also changed the fopen to _wfopen; the DllCall is now done with "wstr" instead of "str". Everything works fine now !! Link to comment Share on other sites More sharing options...
czardas Posted October 11, 2013 Share Posted October 11, 2013 That's great. You solved it yourself really but I'm happy my post was useful to you. operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now