cGetFile32() about traditional Chinese characters

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

cGetFile32() about traditional Chinese characters

Post by ssbbs »

A very strange thing happened!

.prg encode is ansi/big5

Code: Select all | Expand


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


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
User avatar
karinha
Posts: 7951
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Been thanked: 3 times
Contact:

Re: cGetFile32() about traditional Chinese characters

Post by karinha »

Try using,

Code: Select all | Expand


   Lfn2Sfn(cDir)
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
ssbbs
Posts: 104
Joined: Mon Oct 17, 2005 3:03 am
Location: Taiwan

Re: cGetFile32() about traditional Chinese characters

Post by ssbbs »

karinha wrote:Try using,

Code: Select all | Expand


   Lfn2Sfn(cDir)
 


Regards, saludos.


I think this should not be the correct solution!
line ID: ssbbstw
WeChat ID: ssbbstw
alfredlam
Posts: 14
Joined: Tue Aug 21, 2012 2:13 am

Re: cGetFile32() about traditional Chinese characters

Post by alfredlam »

I have the same problem too, is there any solution ?
User avatar
richard-service
Posts: 808
Joined: Tue Oct 16, 2007 8:57 am
Location: New Taipei City, Taiwan
Has thanked: 2 times
Contact:

Re: cGetFile32() about traditional Chinese characters

Post by richard-service »

UP+
Best Regards,

Richard

Harbour 3.2.0dev (r2402101027) => Borland C++ v7.7 32bit
MySQL v8.0 /ADS v10
Harbour 3.2.0dev (r2011030937) => Borland C++ v7.4 64bit
User avatar
karinha
Posts: 7951
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Been thanked: 3 times
Contact:

Re: cGetFile32() about traditional Chinese characters

Post by karinha »

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


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

Re: cGetFile32() about traditional Chinese characters

Post by ssbbs »

I have solved this problem!
line ID: ssbbstw
WeChat ID: ssbbstw
alfredlam
Posts: 14
Joined: Tue Aug 21, 2012 2:13 am

Re: cGetFile32() about traditional Chinese characters

Post by alfredlam »

ssbbs wrote:I have solved this problem!


Would you please post the solution.

regards
User avatar
ssbbs
Posts: 104
Joined: Mon Oct 17, 2005 3:03 am
Location: Taiwan

Re: cGetFile32() about traditional Chinese characters

Post by ssbbs »

line ID: ssbbstw
WeChat ID: ssbbstw
User avatar
karinha
Posts: 7951
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Been thanked: 3 times
Contact:

Re: cGetFile32() about traditional Chinese characters

Post by karinha »



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


cGetDir.obj
test.prg
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
alfredlam
Posts: 14
Joined: Tue Aug 21, 2012 2:13 am

Re: cGetFile32() about traditional Chinese characters

Post by alfredlam »

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

Re: cGetFile32() about traditional Chinese characters

Post by ssbbs »

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


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
Post Reply