FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Bug? cGetDir() on utf8
Posts: 129
Joined: Mon Oct 17, 2005 03:03 AM
Bug? cGetDir() on utf8
Posted: Thu Apr 16, 2020 02:57 PM
Code (fw): Select all Collapse
        HB_SetCodePage("UTF8")
        HB_CDPSELECT("UTF8")
        //
        FW_SetUnicode(.T.)
        cIniDir:="c:/temp/中文目錄"
        cTmpDir := AllTrim( cGetDir( "請選擇圖片存放路徑",  cIniDir, .T. ))


please change '/' to '\'


Title is ugly code!!

line ID: ssbbstw

WeChat ID: ssbbstw
Posts: 8523
Joined: Tue Dec 20, 2005 07:36 PM
Re: Bug? cGetDir() on utf8
Posted: Thu Apr 16, 2020 03:18 PM
As I don't understand Chinese, try this model.

Code (fw): Select all Collapse
#include "FiveWin.ch"

#define BIF_NONEWFOLDERBUTTON  0x200
#define BIF_RETURNONLYFSDIRS   0x0001
#define BIF_DONTGOBELOWDOMAIN  0x0002
#define BIF_STATUSTEXT         0x0004
#define BIF_RETURNFSANCESTORS  0x0008
#define BIF_EDITBOX            0x0010
#define BIF_VALIDATE           0x0020
#define BIF_NEWDIALOGSTYLE     0x0040
#define BIF_USENEWUI  (BIF_NEWDIALOGSTYLE | BIF_EDITBOX)
#define BIF_BROWSEINCLUDEURLS  0x0080
#define BIF_BROWSEFORCOMPUTER  0x1000
#define BIF_BROWSEFORPRINTER   0x2000
#define BIF_BROWSEINCLUDEFILES 0x4000
#define BIF_SHAREABLE          0x8000
#define MAX_PATH 260

FUNCTION Main()

   LOCAL cTitle, cPath, cCarpDest, cPathDest

   cTitle    := "Seleccione Carpeta"

   cPath := GETCURDIR()

   cCarpDest := "Seleccione la carpeta donde copiar las novedades"

   cPathDest := cGetDir( cTitle, cPath,, cCarpDest,                     ;
                         BIF_RETURNONLYFSDIRS + BIF_DONTGOBELOWDOMAIN + ;
                         BIF_USENEWUI + BIF_NONEWFOLDERBUTTON )

   IF .NOT. EMPTY( cPathDest )
      ? cPathDest
   ENDIF

RETURN NIL


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 129
Joined: Mon Oct 17, 2005 03:03 AM
Re: Bug? cGetDir() on utf8
Posted: Thu Apr 16, 2020 03:37 PM
karinha wrote:As I don't understand Chinese, try this model.

Code (fw): Select all Collapse
#include "FiveWin.ch"

#define BIF_NONEWFOLDERBUTTON  0x200
#define BIF_RETURNONLYFSDIRS   0x0001
#define BIF_DONTGOBELOWDOMAIN  0x0002
#define BIF_STATUSTEXT         0x0004
#define BIF_RETURNFSANCESTORS  0x0008
#define BIF_EDITBOX            0x0010
#define BIF_VALIDATE           0x0020
#define BIF_NEWDIALOGSTYLE     0x0040
#define BIF_USENEWUI  (BIF_NEWDIALOGSTYLE | BIF_EDITBOX)
#define BIF_BROWSEINCLUDEURLS  0x0080
#define BIF_BROWSEFORCOMPUTER  0x1000
#define BIF_BROWSEFORPRINTER   0x2000
#define BIF_BROWSEINCLUDEFILES 0x4000
#define BIF_SHAREABLE          0x8000
#define MAX_PATH 260

FUNCTION Main()

   LOCAL cTitle, cPath, cCarpDest, cPathDest

   cTitle    := "Seleccione Carpeta"

   cPath := GETCURDIR()

   cCarpDest := "Seleccione la carpeta donde copiar las novedades"

   cPathDest := cGetDir( cTitle, cPath,, cCarpDest,                     ;
                         BIF_RETURNONLYFSDIRS + BIF_DONTGOBELOWDOMAIN + ;
                         BIF_USENEWUI + BIF_NONEWFOLDERBUTTON )

   IF .NOT. EMPTY( cPathDest )
      ? cPathDest
   ENDIF

RETURN NIL


Regards, saludos.


Sorry!! I test it and still fail.
line ID: ssbbstw

WeChat ID: ssbbstw
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: Bug? cGetDir() on utf8
Posted: Thu Apr 16, 2020 05:09 PM

you can try this

cDirTmp:=OemToAnsi(HB_UTF8ToStr(cGetDir()))

Posts: 129
Joined: Mon Oct 17, 2005 03:03 AM
Re: Bug? cGetDir() on utf8
Posted: Fri Apr 17, 2020 01:49 AM
Natter wrote:you can try this

cDirTmp:=OemToAnsi(HB_UTF8ToStr(cGetDir()))


There are two problems!!
1. Title is showing garbled characters.
2. The initial directory is not expanded

line ID: ssbbstw

WeChat ID: ssbbstw
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Bug? cGetDir() on utf8
Posted: Sun Apr 19, 2020 02:33 AM
The present implementation has limitations in Unicode support.

If the user selects a folder containting Unicode characters, the function returns the Unicode test correctly.

Limitations:
1) Title of the dialog can not be Unicode. This is provided in next version.
Sencond title, inside the dialog can be Unicode even in this version
2) Initdir can not be Unicode text. We are still to find a solution.

With the present version, this can be tried:
Code (fw): Select all Collapse
? cGetDir( "", cInitDir, nil, "請選擇圖片存放路徑" )
// cInitDir can not contain Unicode characters"




In the next version to be released soon we can have dialog title in Unicode
Code (fw): Select all Collapse
   local cTitle   := "請選擇圖片存放路徑"
   ? cGetDir( cTitle, cInitDir, nil, cTitle + " 中文目錄" )




Still, cInitDir can not contain Unicode path. We are working on it.
Regards



G. N. Rao.

Hyderabad, India
Posts: 129
Joined: Mon Oct 17, 2005 03:03 AM
Re: Bug? cGetDir() on utf8
Posted: Sun Apr 19, 2020 08:59 AM
I have solved this problem!
line ID: ssbbstw

WeChat ID: ssbbstw
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Bug? cGetDir() on utf8
Posted: Sun Apr 19, 2020 09:52 AM

Can you please share with us how did you solve this problem?

Regards



G. N. Rao.

Hyderabad, India
Posts: 129
Joined: Mon Oct 17, 2005 03:03 AM
Re: Bug? cGetDir() on utf8
Posted: Sun Apr 19, 2020 01:27 PM
nageswaragunupudi wrote:Can you please share with us how did you solve this problem?

Give me some rewards, ex: free update once! :-)
line ID: ssbbstw

WeChat ID: ssbbstw
Posts: 866
Joined: Tue Oct 16, 2007 08:57 AM
Re: Bug? cGetDir() on utf8
Posted: Thu Jul 09, 2020 11:29 AM

Hi Mr.Rao

Any news?

Best Regards,



Richard



Harbour 3.2.0dev (r2503251254) => Borland C++ v7.7 32bit

MySQL v8.0

Harbour 3.2.0dev (r2503251254) => Borland C++ v7.7 64bit

Continue the discussion