Page 1 of 1

cGetFile32() about traditional Chinese characters

Posted: Sat Aug 07, 2021 9:09 am
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
}
 

Re: cGetFile32() about traditional Chinese characters

Posted: Sun Aug 08, 2021 12:55 am
by karinha
Try using,

Code: Select all | Expand


   Lfn2Sfn(cDir)
 


Regards, saludos.

Re: cGetFile32() about traditional Chinese characters

Posted: Sun Aug 08, 2021 1:03 am
by ssbbs
karinha wrote:Try using,

Code: Select all | Expand


   Lfn2Sfn(cDir)
 


Regards, saludos.


I think this should not be the correct solution!

Re: cGetFile32() about traditional Chinese characters

Posted: Tue Nov 23, 2021 7:35 am
by alfredlam
I have the same problem too, is there any solution ?

Re: cGetFile32() about traditional Chinese characters

Posted: Tue Nov 23, 2021 8:15 am
by richard-service
UP+

Re: cGetFile32() about traditional Chinese characters

Posted: Thu Nov 25, 2021 6:10 pm
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.

Re: cGetFile32() about traditional Chinese characters

Posted: Fri Nov 26, 2021 11:09 am
by ssbbs
I have solved this problem!

Re: cGetFile32() about traditional Chinese characters

Posted: Tue Nov 30, 2021 7:41 am
by alfredlam
ssbbs wrote:I have solved this problem!


Would you please post the solution.

regards

Re: cGetFile32() about traditional Chinese characters

Posted: Tue Nov 30, 2021 8:39 am
by ssbbs

Re: cGetFile32() about traditional Chinese characters

Posted: Tue Nov 30, 2021 12:07 pm
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.

Re: cGetFile32() about traditional Chinese characters

Posted: Fri Dec 03, 2021 4:23 am
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

Re: cGetFile32() about traditional Chinese characters

Posted: Fri Dec 03, 2021 8:55 am
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 );

}