Forum > Windows

File paths on Windows

<< < (2/3) > >>

marcov:
Thaddy: Apparently you don't understand the current unicode possibilities (of FPC 3+)

If you use system,sysutils units, and no direct windows calls, a lazarus program that is set to utf8 should work.

The easiest way to check this is probably to output inttostr(defaultsystemcodepage) to a memo and check it is 65001

Thaddy:

--- Quote from: marcov on November 24, 2021, 03:06:40 pm ---Thaddy: Apparently you don't understand the current unicode possibilities (of FPC 3+)

If you use system,sysutils units, and no direct windows calls, a lazarus program that is set to utf8 should work.

--- End quote ---
No I do understand. But regarding the file system API on Windows this is not enough. You will need to specify unicodestring. Also goes for the registry if there occur very long paths.
You should have written in most (99%) but not all cases.
Especially very low level system access can still bite you and my guess is that is what happened here.

marcov:

--- Quote from: Thaddy on November 24, 2021, 03:13:01 pm ---But regarding the file system API on Windows this is not enough. You will need to specify unicodestring. Also goes for the registry if there occur very long paths.
You should have written in most (99%) but not all cases.

--- End quote ---

No just tick the utf8 box in the application/manifest/resource tab. The long file name one is there too.

Bart:
Maybe wait until Ñuño_Martínez replies, otherwise it's just guess work.

Bart

Ñuño_Martínez:
Sorry, there were busy weeks.


--- Quote from: Bart on November 24, 2021, 01:53:26 pm ---Is you application using LCL or LazUtil
--- End quote ---

No, it isn't.  I'm not using GUI.


--- Quote from: Bart on November 24, 2021, 01:53:26 pm ---Can you show us the relevant part of the code and exactly at what line it fails?
I suppose you use False for the "Global" paramater of GetAppConfigDir?
--- End quote ---
I use GetAppConfigFile instead:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---    fFileName := GetAppConfigFile (FALSE); 
Then, I use it to create the directory and the file:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---(* Saves changes. *)  PROCEDURE TmngConfiguration.Save;  VAR    DirPath: STRING;  BEGIN  { Be sure the directory exists. }    DirPath := ExtractFileDir (fFileName);    IF NOT DirectoryExists (DirPath) THEN      IF NOT CreateDir (DirPath) THEN      { Changed this to avoid problems with bad encoded file names        (i.e. Windows).  Now just put it down in to the log file.        RAISE mngConfigException.CreateFmt (COULDNT_SAVE_CFG_FILE, [fFileName]);      }        mngApplication.LogFmt (etWarning, COULDNT_SAVE_CFG_FILE, [fFileName]);   { Save the file. }    IF NOT al_save_config_file (fFileName, fConfig) THEN    { See previous long comment.      RAISE mngConfigException.CreateFmt (COULDNT_SAVE_CFG_FILE, [fFileName]);    }      mngApplication.LogFmt (etWarning, COULDNT_SAVE_CFG_FILE, [fFileName]);  { Event. }    fOnSave.Notify  END; As I've said, it creates the directory but fails creating the file.

al_save_config_file is from Allegro.




--- Quote from: loaded on November 24, 2021, 02:21:35 pm ---I had a similar problem before. I think it was solved with the following.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.Button1Click(Sender: TObject);var  fname:UTF8String='C:\Users\mali.aydin\Desktop\Türkçe\ĞÜŞİÖÇ.txt';begin  // UTF8ToISO_8859_1 uses add LConvEncoding.;  ExecuteProcess('explorer.exe', '/select,'+PChar(UTF8ToISO_8859_1(fname)), []);end;  
--- End quote ---
I'll see how I can use that UTF8ToISO_8859_1.

Anyway what if it is installed in a non-western computer (for example Japan)?


--- Quote from: Bart on November 24, 2021, 06:48:57 pm ---Maybe wait until Ñuño_Martínez replies, otherwise it's just guess work.

Bart

--- End quote ---
My bad.  As I've said it were busy weeks.

I must say that I don't care to be compatible with older than Windows 7 (at themoment).

Also, the program creates the file in my own Win7 computer and in two Win10 computer I have access to:  I have limited access to one that fails.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version