Recent

Author Topic: GetUserDir  (Read 6559 times)

LA.Center

  • Full Member
  • ***
  • Posts: 244
    • LA.Center
GetUserDir
« on: December 08, 2011, 07:19:07 pm »
GetUserDir does not support Chinese/Russian chars, need a workaround.

Code: [Select]
var
  _userpath: string;
begin
  _userpath := GetUserDir;
...

comes out like c:\Users\???????????\

Bart

  • Hero Member
  • *****
  • Posts: 5713
    • Bart en Mariska's Webstek
Re: GetUserDir
« Reply #1 on: December 08, 2011, 07:40:34 pm »
Maybe use SysToUtf8() if you are displaying it in an LCL application?

Bart

LA.Center

  • Full Member
  • ***
  • Posts: 244
    • LA.Center
Re: GetUserDir
« Reply #2 on: December 08, 2011, 08:17:29 pm »
Thx for the info, yes I tried that already and it works for Turkish and Slavish chars but not for Greek, Russian, Chinese -> the higher set chars.

I do display it in a FileEdit and a normal Edit and it is really a problem.

Bart

  • Hero Member
  • *****
  • Posts: 5713
    • Bart en Mariska's Webstek
Re: GetUserDir
« Reply #3 on: December 08, 2011, 08:38:42 pm »
If you are on windows, you could try implementing a GetSpecialDir() function that uses SHGetFolderPathW instead of SHGetFolderPathA?
Then convert the WideString to Utf8?

The GetSpecialDir source is in rtl\win\sysutils.pp

Bart

LA.Center

  • Full Member
  • ***
  • Posts: 244
    • LA.Center
Re: GetUserDir
« Reply #4 on: December 13, 2011, 03:46:05 am »
I need it for all platforms, its weird that it does not work though.

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: GetUserDir
« Reply #5 on: December 13, 2011, 10:43:56 am »
I need it for all platforms, its weird that it does not work though.

The Free Pascal RTL does not yet support Unicode, although maybe FPC 2.8 will support. So nothing from the RTL supports Unicode reliably at the moment.

If you track GetUserDir is from the unit SysUtils which is inside the RTL http://www.freepascal.org/docs-html/rtl/sysutils/getuserdir.html

Lazarus has it's own set of routines in the package lazutils in units like fileutils, lazutf8sysutils and lazutf8classes, but those are very far from complete. Of course patches are welcome to implement missing parts, you can see how fileutils implements various things and do something similar.

 

TinyPortal © 2005-2018