FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour cGetFile32() about traditional Chinese characters
Posts: 129
Joined: Mon Oct 17, 2005 03:03 AM
cGetFile32() about traditional Chinese characters
Posted: Sat Aug 07, 2021 09:09 AM
A very strange thing happened!

.prg encode is ansi/big5
Code (fw): Select all Collapse
#include 'fivewin.ch'
REQUEST HB_CODEPAGE_BIG5
func   test()
Local  oDlg, oBtn, oGet, oProgress
Priv   cSrc := space(256),;
       cDes := space(256),;
       cProgressText := ''
       //
       hb_cdpSelect('BIG5')
       //
       DEFINE DIALOG oDlg RESOURCE "FUN01_DLG" TITLE '工具程式'
              oDlg:bKeyDown := {|nKey|If( nKey == VK_ESCAPE, oDlg:End(), NIL )}
       //
       REDEFINE BUTTON oBtn ID 101 OF oDlg UPDATE;
                ACTION SelectFile(1, oDlg)
       REDEFINE GET oGet VAR cSrc ID 201 OF oDlg UPDATE
       //
       REDEFINE BUTTON oBtn ID 102 OF oDlg UPDATE;
                ACTION SelectFile(2, oDlg)
       REDEFINE GET oGet VAR cDes ID 202 OF oDlg UPDATE
       //
       REDEFINE SAY oSay VAR cProgressText ID 301 OF oDlg UPDATE
       REDEFINE PROGRESS oProgress ID 401 OF oDlg
       //
       REDEFINE BUTTON oBtn ID 901 OF oDlg UPDATE;
                ACTION testrun() CANCEL
       REDEFINE BUTTON oBtn ID 902 OF oDlg UPDATE;
                ACTION oDlg:End() CANCEL
       //
       ACTIVATE DIALOG oDlg
return

func   testrun()
Local  hDes, cDes
Local  hSrc := fOpen( cSrc, 1 )
       // test fail!!
       If fError() != 0
          msgstop( 'Source file:['+cSrc+']Open fail!['+Str(fError())+']', "Error!"+ProcName()+"("+LTrim( Str( ProcLine()))+")" )
       Else
          msgInfo('Open Success')
          fClose(hSrc)
       EndIf

       // test ok
       cDes := 'D:\myprog\win\six\prg6\2020.03.31\071002(38總結)圖表-00.txt'
       hDes := fOpen( cDes, 1 )
       // test fail!!
       If fError() != 0
          msgstop( 'Source File:['+cDes+']Open Fila!['+Str(fError())+']', "Error!"+ProcName()+"("+LTrim( Str( ProcLine()))+")" )
       Else
          msgInfo('Open Success')
          fClose(hDes)
       EndIf
return

func   SelectFile(nType, oDlg)
Local nHrc
Local  cFile  := cGetFile32( "Text|*.txt", "Select File", 0, .T., .T. )
       If ! Empty( cFile )
          If nType == 1
             cSrc := cFile
//---[test fail]---
             hSrc := fOpen( cFile, 1 )
             If fError() != 0
                msgstop( 'Source file:['+cSrc+']Open fail!['+Str(fError())+']', "Error!"+ProcName()+"("+LTrim( Str( ProcLine()))+")" )
             Else
                msgInfo('Open Success')
                fClose(hSrc)
             EndIf
          Else
             cDes := cFile
          EndIf
          oDlg:UpDate()
       EndIf
RETURN NIL


Select the file through cGetFile32(), open the file error If the file name contains Chinese characters
filename ex: 'D:\myprog\win\six\prg6\2020.03.31\071002(38總結)圖表-00.txt'

test.rc
Code (fw): Select all Collapse
FUN01_DLG DIALOG 6, 5, 298, 96
EXSTYLE WS_EX_DLGMODALFRAME
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "功能選擇"
FONT 12, "細明體"
{
 CONTROL "Select Source:", 101, "button", BS_PUSHBUTTON | BS_CENTER | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 3, 4, 72, 12
 CONTROL "Select destination:", 102, "button", BS_PUSHBUTTON | BS_CENTER | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 3, 16, 72, 12
 CONTROL "123456789", 201, "edit", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 76, 4, 220, 12
 CONTROL "123456789", 202, "edit", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 76, 16, 220, 12
 CONTROL "[&Y]Run", 901, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 89, 33, 60, 20
 CONTROL "[&X]Exit", 902, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 149, 33, 60, 20
 CONTROL "", 401, "msctls_progress32", WS_CHILD | WS_VISIBLE | WS_BORDER, 4, 71, 291, 17
 CONTROL "", 301, "static", SS_LEFT | WS_CHILD | WS_VISIBLE, 4, 60, 290, 9
}
line ID: ssbbstw

WeChat ID: ssbbstw
Posts: 8523
Joined: Tue Dec 20, 2005 07:36 PM
Re: cGetFile32() about traditional Chinese characters
Posted: Sun Aug 08, 2021 12:55 AM
Try using,

Code (fw): Select all Collapse
   Lfn2Sfn(cDir)


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: cGetFile32() about traditional Chinese characters
Posted: Sun Aug 08, 2021 01:03 AM
karinha wrote:Try using,

Code (fw): Select all Collapse
   Lfn2Sfn(cDir)


Regards, saludos.


I think this should not be the correct solution!
line ID: ssbbstw

WeChat ID: ssbbstw
Posts: 14
Joined: Tue Aug 21, 2012 02:13 AM
Re: cGetFile32() about traditional Chinese characters
Posted: Tue Nov 23, 2021 07:35 AM

I have the same problem too, is there any solution ?

Posts: 866
Joined: Tue Oct 16, 2007 08:57 AM
Re: cGetFile32() about traditional Chinese characters
Posted: Tue Nov 23, 2021 08:15 AM

UP+

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
Posts: 8523
Joined: Tue Dec 20, 2005 07:36 PM
Re: cGetFile32() about traditional Chinese characters
Posted: Thu Nov 25, 2021 06:10 PM
Este programa es incorrecto. Vuelva a hacerlo en inglés o español y pruébelo, no funcionará.
No puedo probar aquí, está en chino y Windows en portugués no proporciona caracteres chinos.
Si lo entiendo, desea tomar un archivo .TXT y escribir en D: \ ..., pero la lógica es incorrecta.

También prueba así:

This program is wrong. Redo it in English or Spanish, and test it, it won't work.
I can't test here, it's in Chinese, and Windows in Portuguese doesn't provide Chinese characters.
If I understand, you want to grab a .TXT file and Write to D:\..., but the logic is wrong.

Also test like this:


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

REQUEST HB_CODEPAGE_BIG5
REQUEST HB_CODEPAGE_UTF8

MEMVAR cSrc, cDes, cProgressText

FUNCTION SSBbs_Test()

   LOCAL  oDlg, oBtn, oGet, oProgress, oSay

   hb_cdpSelect( 'BIG5' )
   hb_cdpSelect( "UTF8" )
   hb_cdpIsCharIdx( "BIG5", .T. )

   FW_SetUnicode( .F. )

   cSrc          := SPACE(256)
   cDes          := SPACE(256)
   cProgressText := ''

...

  LOCAL cFile := cGetFile( "इनमें से किसी को  (*.bmp,*.txt)|*.bmp;*.txt|", ;
                            "किसी एक को चुनिये " )


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: cGetFile32() about traditional Chinese characters
Posted: Fri Nov 26, 2021 11:09 AM

I have solved this problem!

line ID: ssbbstw

WeChat ID: ssbbstw
Posts: 14
Joined: Tue Aug 21, 2012 02:13 AM
Re: cGetFile32() about traditional Chinese characters
Posted: Tue Nov 30, 2021 07:41 AM
ssbbs wrote:I have solved this problem!


Would you please post the solution.

regards
Posts: 129
Joined: Mon Oct 17, 2005 03:03 AM
Re: cGetFile32() about traditional Chinese characters
Posted: Tue Nov 30, 2021 08:39 AM
line ID: ssbbstw

WeChat ID: ssbbstw
Posts: 8523
Joined: Tue Dec 20, 2005 07:36 PM
Re: cGetFile32() about traditional Chinese characters
Posted: Tue Nov 30, 2021 12:07 PM
ssbbs wrote:Reference URL: http://www4.zzz.com.tw/phpBB3/viewtopic.php?f=2&t=350


Buen día. Este cGetDir.Obj, ¿se generó en qué idioma (FiveWin)? ¿Tiene la fuente (código) de este cGetdir?

Good Morning. This cGetDir.Obj, was generated in what language(FiveWin)? Do you have the source(Code) of this cGetdir?


Code (fw): Select all Collapse
cGetDir.obj
test.prg


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 14
Joined: Tue Aug 21, 2012 02:13 AM
Re: cGetFile32() about traditional Chinese characters
Posted: Fri Dec 03, 2021 04:23 AM

CGETDIR.OBJ Linking Error
Turbo Incremental Link 6.70 Copyright (c) 1997-2014 Embarcadero Technologies, Inc.
Error: Unresolved external 'CPPdebugHook' referenced from C:\BCC582\LIB\CW32.LIB|xx
Error: Unresolved external '
_hInstance' referenced from C:\BCC582\LIB\CW32.LIB|_fastmm
Error: Unresolved external '
_System__GetTls' referenced from C:\BCC582\LIB\CW32.LIB|xxv
Error: Unresolved external '_fw_retWide' referenced from C:\PRG\NEWKSU\OBJ\CGETDIR.OBJ

seems cGetdir.obj needs to call other lib to work

Posts: 129
Joined: Mon Oct 17, 2005 03:03 AM
Re: cGetFile32() about traditional Chinese characters
Posted: Fri Dec 03, 2021 08:55 AM
alfredlam wrote:CGETDIR.OBJ Linking Error
Turbo Incremental Link 6.70 Copyright (c) 1997-2014 Embarcadero Technologies, Inc.
Error: Unresolved external '___CPPdebugHook' referenced from C:\BCC582\LIB\CW32.LIB|xx
Error: Unresolved external '__hInstance' referenced from C:\BCC582\LIB\CW32.LIB|_fastmm
Error: Unresolved external '___System__GetTls' referenced from C:\BCC582\LIB\CW32.LIB|xxv
Error: Unresolved external '_fw_retWide' referenced from C:\PRG\NEWKSU\OBJ\CGETDIR.OBJ

seems cGetdir.obj needs to call other lib to work


CW32.lib is borland C++ library.
fw_retWide() is from: \fwh2006\source\winapi\getfile.c

Code (fw): Select all Collapse
void fw_retWide( LPWSTR pWide )
{
    LPSTR pText;

   pText    = UTF16toSTR8( pWide, fw_wcslen( pWide ) );
   hb_retc( pText );
   hb_xfree( ( void * ) pText );

}
line ID: ssbbstw

WeChat ID: ssbbstw

Continue the discussion