Welcome, Guest
Username: Password: Remember me
General discussions, feature requests for CodeTyphon Project and discussions that don't fit in any of the other specific CodeTyphon forum categories.
  • Page:
  • 1

TOPIC:

CreateDir not work. 8 years 11 months ago #7443

  • Reinier Romero Mir
  • Reinier Romero Mir's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 18
  • Thank you received: 1
Here i try to recreate my problem in a simple example, is a typically unicode problem but i not find a solution, occurs only in Windows when i try to get user folder and create a new folder inside it but is not soo simple
consider the user name 'Niño López' and the foldor is c:\documents and settings\Niño López\

here is the example code:
procedure example();
var 
    userdir:string;
    {$IFDEF WINDOWS}
      registro:TRegistry;
    {$ENDIF}
begin
  userdir:=UTF8ToSys(GetUserDir()+'New Folder');
      {$IFDEF WINDOWS}
        registro:=TRegistry.Create;
        registro.RootKey:=HKEY_CURRENT_USER;
        registro.OpenKey('Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\',false);
        userdir:=SysToUTF8(registro.ReadString('Personal')+PathDelim+'New Folder');
        registro.CloseKey;
        registro.Free;
      {$ENDIF}   
     Form2.Edit1.Text:=userdir;          // The user can modify the userdir after create it
     Form2.ShowModal;
     if not DirectoryExists(Form2.Edit1.Text) then
        CreateDir(UTF8ToSys(Form2.Edit1.Text)); 
end;
This work good in FPC 2.6.4 but not in new versions, the 'userdir' is represented with rare characters or is not create, any solution?
Attachments:

Please Log in or Create an account to join the conversation.

Last edit: by Reinier Romero Mir. Reason: a most suggest title

CreateDir not work. 8 years 11 months ago #7445

  • usbdoo
  • usbdoo's Avatar
  • Visitor
  • Visitor
Verified on Debian 8 Jessie CreateDir correctly work .
CT 5.3

Please Log in or Create an account to join the conversation.

Last edit: by usbdoo.

CreateDir not work. 8 years 11 months ago #7446

  • Tony_O_Gallos
  • Tony_O_Gallos's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Ελεύθερο λογισμικό ή θάνατος
  • Posts: 84
  • Thank you received: 23
Hi Segator,

try to use DirectoryExistsUTF8 and CreateDirUTF8.
The use of these functions is described in wiki.freepascal.org/Multiplatform_Programming_Guide
About FPC recent versions: wiki.lazarus.freepascal.org/FPC_Unicode_support
There are some options for UTF8 in LCL in Project/Project options.../Compiler Options (The button "Set UTF-8 in RTL")

Please Log in or Create an account to join the conversation.

CreateDir not work. 8 years 11 months ago #7449

  • Reinier Romero Mir
  • Reinier Romero Mir's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 18
  • Thank you received: 1

usbdoo wrote: Verified on Debian 8 Jessie CreateDir correctly work .
CT 5.3

Yes usbdoo the problem is only in windows, in part because is not posible create the user name "Niño López" in unix systems :).

Please Log in or Create an account to join the conversation.

CreateDir not work. 8 years 11 months ago #7450

  • Reinier Romero Mir
  • Reinier Romero Mir's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 18
  • Thank you received: 1

Tony_O_Gallos wrote: Hi Segator,

try to use DirectoryExistsUTF8 and CreateDirUTF8.
The use of these functions is described in wiki.freepascal.org/Multiplatform_Programming_Guide
About FPC recent versions: wiki.lazarus.freepascal.org/FPC_Unicode_support
There are some options for UTF8 in LCL in Project/Project options.../Compiler Options (The button "Set UTF-8 in RTL")

Hello tony, yes this maybe work, the FPC team write this methods to support unicode (not present in FPC 2.6.4), but not exists a "GetUserDirUTF8" or "TRegistry.ReadStringUTF8" so, exist a lost of information before create the new folder, when you obtain the user folder:
{$IFDEF WINDOWS}
        registro:=TRegistry.Create;
        registro.RootKey:=HKEY_CURRENT_USER;
        registro.OpenKey('Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\',false);
        userdir:=SysToUTF8(registro.ReadString('Personal')+PathDelim+'New Folder');
        registro.CloseKey;
        registro.Free;
      {$ENDIF}   
     Form2.Edit1.Text:=userdir;
in this point the edit text not show the ó and Ñ characters :( , try the attachment in CT 5.3, about the UTF8 in LCL you mean this??:

Please Log in or Create an account to join the conversation.

Last edit: by Reinier Romero Mir. Reason: add more information
  • Page:
  • 1