TGet Unicode problem

TGet Unicode problem

Postby Horizon » Fri Aug 17, 2018 2:57 pm

Hi,

As you know the sample program. I dont use unicode. (FW_SetUnicode( .f. )). I try both .T. and .F. in TGet():lDefaultANSI := ??.

How can I solve this problem?

Thanks,

sample program
Code: Select all  Expand view
#include "FiveWin.ch"

function Main()
   LOCAL oDlg, oGet
   LOCAL cCad := pad("Testing Gets",40)
   LOCAL nNum := 0
   LOCAL dDat := Date()
   
    FW_SetUnicode( .f. )
    TGet():lDefaultANSI := .F.
   

   Set century On
   Set Date Ansi
   Set Date format "mm/dd/yyyy"

   SET _3DLOOK ON

//   DEFINE DIALOG oDlg TITLE "TGet from " + FWDESCRIPTION
   DEFINE DIALOG oDlg from 0,0 to 180,600 pixel TITLE "TGet from " + FWDESCRIPTION

   @ 10, 15 SAY "Text..:" OF oDlg PIXEL
   @ 10, 35 GET oGet VAR cCad OF oDlg SIZE 240, 10 PIXEL ;
        ACTION (cCad := cGetFile32(cCad))

   @ 70,   15 BUTTON "&Ok" OF oDlg SIZE 30, 12 PIXEL ACTION oDlg:End()
   @ 70,   65 BUTTON "&Cancel" SIZE 30, 12 PIXEL OF oDlg ACTION oDlg:End() CANCEL
   
   // TGet():SetColorFocus( nRGB( 200, 120, 120 ) )

   ACTIVATE DIALOG oDlg CENTERED
   
  MsgInfo(cCad)

return nil


Image
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: TGet Unicode problem

Postby Horizon » Mon Aug 27, 2018 12:50 pm

?
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: TGet Unicode problem

Postby nageswaragunupudi » Mon Aug 27, 2018 5:23 pm

This works if we set FW_SetUnicode( .t. ).
Without that, I could not find a way. Probably we need to set the right codepage for the Turkish language. I could not figure out what it is. Maybe other programmers from Turkey can help.

Note:
? command and all Msg* functions like MsgInfo() display Unicode characters even in a non-Unicode application.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: TGet Unicode problem

Postby Horizon » Mon Aug 27, 2018 6:05 pm

Hi Mr. Rao,

You are right if we set FW_SetUnicode( .t. ). but there is also another problem. I can not open the selected file in GetExcelRange() function. File(cSelectedfile) is also says .f.

I have found a workaround like this. It is funny but it works.

Code: Select all  Expand view
cFileName := MyUnicodeToAnsi(cGetFile32(oData:cDosya))

...
FUNCTION MyUnicodeToAnsi(cText)
    Copy_Clipboard(cText)
    cText := Get_Clipboard()   
RETURN cText
*-------------------------------------------------------------------------------
PROCEDURE Copy_Clipboard(cText)
LOCAL oClp, i
DEFAULT cText := ""
    DEFINE CLIPBOARD oClp OF oApp:oDlg
    cText := ALLTRIM(cText)
    oClp:SetText(cText)
    oClp:End()
RETURN
*-------------------------------------------------------------------------
FUNCTION Get_Clipboard()
LOCAL oClipBoard, oDlg, i, cText:=""

    DEFINE DIALOG oDlg TITLE "Test"
    DEFINE CLIPBOARD oClipBoard OF oDlg FORMAT TEXT
    ACTIVATE DIALOG oDlg CENTERED ON INIT ( cText := ALLTRIM(oClipBoard:GetText()),;
                                        oClipBoard:End(), oDlg:End())
RETURN cText

 
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: TGet Unicode problem

Postby nageswaragunupudi » Mon Aug 27, 2018 7:05 pm

I think with these settings you shd get everything work.

Code: Select all  Expand view
  FW_SetUnicode( .t. )
   HB_CDPSELECT( "UTF8" )
 

With this, ExcelRange() should also work and clipboard and everything, without any workarounds.
Please try
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: TGet Unicode problem

Postby Horizon » Tue Aug 28, 2018 1:59 pm

nageswaragunupudi wrote:I think with these settings you shd get everything work.

Code: Select all  Expand view
  FW_SetUnicode( .t. )
   HB_CDPSELECT( "UTF8" )
 

With this, ExcelRange() should also work and clipboard and everything, without any workarounds.
Please try


Hi,

or If we don't want to use UTF8, We can use the unmodified cGetFile32 function as a new function with a different name.

Code: Select all  Expand view
December 2017
=============

* Enhancement: cGetFile(), aGetFiles() and cGetDir() now
work with Unicode file and directory names also, even in
an ANSI application (i.e., even when FW_SetUnicode(.F.) )
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: TGet Unicode problem

Postby nageswaragunupudi » Tue Aug 28, 2018 2:15 pm

or If we don't want to use UTF8, We can use the unmodified cGetFile32 function as a new function with a different name.


Did you try? Are you able to display the result of unmodified cGetFile32() in the Get correctly?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 99 guests