Bug? cGetDir() on utf8

Post Reply
User avatar
ssbbs
Posts: 54
Joined: Mon Oct 17, 2005 3:03 am

Bug? cGetDir() on utf8

Post by ssbbs »

Code: Select all

        HB_SetCodePage("UTF8")
        HB_CDPSELECT("UTF8")
        //
        FW_SetUnicode(.T.)
        cIniDir:="c:/temp/中文目錄"
        cTmpDir := AllTrim( cGetDir( "請選擇圖片存放路徑",  cIniDir, .T. ))
 
please change '/' to '\'


Title is ugly code!!

Image
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Bug? cGetDir() on utf8

Post by karinha »

As I don't understand Chinese, try this model.

Code: Select all

#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
User avatar
ssbbs
Posts: 54
Joined: Mon Oct 17, 2005 3:03 am

Re: Bug? cGetDir() on utf8

Post by ssbbs »

karinha wrote:As I don't understand Chinese, try this model.

Code: Select all

#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.
Natter
Posts: 524
Joined: Mon May 14, 2007 9:49 am

Re: Bug? cGetDir() on utf8

Post by Natter »

you can try this

cDirTmp:=OemToAnsi(HB_UTF8ToStr(cGetDir()))
User avatar
ssbbs
Posts: 54
Joined: Mon Oct 17, 2005 3:03 am

Re: Bug? cGetDir() on utf8

Post by ssbbs »

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

Image
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Bug? cGetDir() on utf8

Post by nageswaragunupudi »

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: Select all

? cGetDir( "", cInitDir, nil, "請選擇圖片存放路徑" )
// cInitDir can not contain Unicode characters"
 
Image

In the next version to be released soon we can have dialog title in Unicode

Code: Select all

   local cTitle   := "請選擇圖片存放路徑"
   ? cGetDir( cTitle, cInitDir, nil, cTitle + " 中文目錄" )
 
Image

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

G. N. Rao.
Hyderabad, India
User avatar
ssbbs
Posts: 54
Joined: Mon Oct 17, 2005 3:03 am

Re: Bug? cGetDir() on utf8

Post by ssbbs »

I have solved this problem!
Image
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Bug? cGetDir() on utf8

Post by nageswaragunupudi »

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

G. N. Rao.
Hyderabad, India
User avatar
ssbbs
Posts: 54
Joined: Mon Oct 17, 2005 3:03 am

Re: Bug? cGetDir() on utf8

Post by ssbbs »

nageswaragunupudi wrote:Can you please share with us how did you solve this problem?
Give me some rewards, ex: free update once! :mrgreen:
User avatar
richard-service
Posts: 583
Joined: Tue Oct 16, 2007 8:57 am
Location: New Taipei City, Taiwan
Contact:

Re: Bug? cGetDir() on utf8

Post by richard-service »

Hi Mr.Rao

Any news?
Regards,

Richard

Harbour 3.2.0dev (r1904111533)/xHarbour 1.2.3 Intl. (SimpLex) (Build 20180818) => Borland C++ v7.4
xHarbour 0.99.71 (SimpLex) => Borland C++ v5.5
MySQL v5.7 /ADS v12
Harbour 3.2.0dev (r1603181642) => Borland C++ v7.4 64bit
Post Reply