cGetFile32() about traditional Chinese characters

cGetFile32() about traditional Chinese characters

Postby ssbbs » Sat Aug 07, 2021 9:09 am

A very strange thing happened!

.prg encode is ansi/big5
Code: Select all  Expand view  RUN

#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 view  RUN

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

Re: cGetFile32() about traditional Chinese characters

Postby karinha » Sun Aug 08, 2021 12:55 am

Try using,

Code: Select all  Expand view  RUN

   Lfn2Sfn(cDir)
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7826
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: cGetFile32() about traditional Chinese characters

Postby ssbbs » Sun Aug 08, 2021 1:03 am

karinha wrote:Try using,

Code: Select all  Expand view  RUN

   Lfn2Sfn(cDir)
 


Regards, saludos.


I think this should not be the correct solution!
line ID: ssbbstw
WeChat ID: ssbbstw
User avatar
ssbbs
 
Posts: 104
Joined: Mon Oct 17, 2005 3:03 am
Location: Taiwan

Re: cGetFile32() about traditional Chinese characters

Postby alfredlam » Tue Nov 23, 2021 7:35 am

I have the same problem too, is there any solution ?
alfredlam
 
Posts: 14
Joined: Tue Aug 21, 2012 2:13 am

Re: cGetFile32() about traditional Chinese characters

Postby richard-service » Tue Nov 23, 2021 8:15 am

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
richard-service
 
Posts: 803
Joined: Tue Oct 16, 2007 8:57 am
Location: New Taipei City, Taiwan

Re: cGetFile32() about traditional Chinese characters

Postby karinha » Thu Nov 25, 2021 6: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: Select all  Expand view  RUN

#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
karinha
 
Posts: 7826
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: cGetFile32() about traditional Chinese characters

Postby ssbbs » Fri Nov 26, 2021 11:09 am

I have solved this problem!
line ID: ssbbstw
WeChat ID: ssbbstw
User avatar
ssbbs
 
Posts: 104
Joined: Mon Oct 17, 2005 3:03 am
Location: Taiwan

Re: cGetFile32() about traditional Chinese characters

Postby alfredlam » Tue Nov 30, 2021 7:41 am

ssbbs wrote:I have solved this problem!


Would you please post the solution.

regards
alfredlam
 
Posts: 14
Joined: Tue Aug 21, 2012 2:13 am

Re: cGetFile32() about traditional Chinese characters

Postby ssbbs » Tue Nov 30, 2021 8:39 am

line ID: ssbbstw
WeChat ID: ssbbstw
User avatar
ssbbs
 
Posts: 104
Joined: Mon Oct 17, 2005 3:03 am
Location: Taiwan

Re: cGetFile32() about traditional Chinese characters

Postby karinha » Tue Nov 30, 2021 12:07 pm



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 view  RUN

cGetDir.obj
test.prg
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7826
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: cGetFile32() about traditional Chinese characters

Postby alfredlam » Fri Dec 03, 2021 4: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
alfredlam
 
Posts: 14
Joined: Tue Aug 21, 2012 2:13 am

Re: cGetFile32() about traditional Chinese characters

Postby ssbbs » Fri Dec 03, 2021 8: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: Select all  Expand view  RUN

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 90 guests