FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour oBtn:ToolTip - UTF8 encoding fails [Unsolved]
Posts: 392
Joined: Tue Mar 10, 2009 11:54 AM
oBtn:ToolTip - UTF8 encoding fails [Unsolved]
Posted: Fri Nov 24, 2023 10:01 AM
UTF8 encoding fails - switches to Ansi - in BUTTON/TButton() and TBtnBmp() ToolTips!

Sample:
Code (fw): Select all Collapse
REQUEST HB_CODEPAGE_UTF8

FUNCTION Main()

   LOCAL oDlg, oBtn

   FW_SetUnicode( .T. )

   DEFINE DIALOG oDlg TITLE "UTF8 encoding fails in Button ToolTips (is Ansi)!"

   @ 2, 2 BTNBMP oBtn TOOLTIP "äöü ß ÄÖÜ éèêë ÉÈÊË"
   
   oBtn := TButtonBmp():New( ;
      2.5, ;                                    // <nRow>     -
      2, ;                                      // <nCol>     -
      "Delete", ;                               // <cCaption> -
      , ;                                       // <oWnd>     -
      {|| ( oBtn:Hide(), oBtn:End() )}, ;       // <bAction>  -
      , ;                                       // <nWidth>   -
      , ;                                       // <nHeight>  -
      , ;                                       // <nHelpId>  -
      , ;                                       // <oFont>    -
      .F., ;                                    // <lDefault> - BS_DEFPUSHBUTTON
      .F., ;                                    // <lPixel>   -
      .F., ;                                    // <lDesign>  -
      , ;                                       // <cMsg>     -
      .F., ;                                    // <lUpdate>  -
      , ;                                       // <bWhen>    -
      , ;                                       // <bValid>   -
      .F., ;                                    // <lCancel>  -
      , ;                                       // <cBitmap>  -
      , ;                                       // <cPosText> -
      "äöü ß ÄÖÜ éèêë ÉÈÊË", ;                  // <cToolTip> -
      , ;                                       // <lFlat>    -
      , ;                                       // <cLayOut>  -
      ;                                         // <lGDIP>    -
      )                                         // CONSTRUCTOR

   ACTIVATE DIALOG oDlg

RETURN NIL


For TButtonBmp() encoding is ok:
Windows 11 Pro 22H2 22621.1848

Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384

Harbour 3.2.0dev (r2008190002)

FWH 23.10 x86
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: oBtn:ToolTip - UTF8 encoding fails [Unsolved]
Posted: Fri Nov 24, 2023 01:13 PM
E asi?
Code (fw): Select all Collapse
// C:\FWH\SAMPLES\BTNFROSE.PRG

#include "FiveWin.ch"

REQUEST HB_LANG_PT
REQUEST HB_CODEPAGE_PT850
REQUEST HB_CODEPAGE_UTF8  // HARBOUR only?

FUNCTION Main()

   LOCAL oDlg, oBtn

   HB_LANGSELECT( 'PT' )
   HB_SETCODEPAGE( "PT850" )
   HB_CDPSELECT("UTF8")

   FW_SetUnicode( .T. )

   DEFINE DIALOG oDlg TITLE "UTF8 encoding fails in Button ToolTips (is Ansi)!"

   @ 2, 2 BTNBMP oBtn TOOLTIP OemToAnsi( "äöü ß ÄÖÜ éèêë ÉÈÊË" )
   
   oBtn := TButtonBmp():New( ;
      2.5, ;                                    // <nRow>     -
      2, ;                                      // <nCol>     -
      "Delete", ;                               // <cCaption> -
      , ;                                       // <oWnd>     -
      {|| ( oBtn:Hide(), oBtn:End() )}, ;       // <bAction>  -
      , ;                                       // <nWidth>   -
      , ;                                       // <nHeight>  -
      , ;                                       // <nHelpId>  -
      , ;                                       // <oFont>    -
      .F., ;                                    // <lDefault> - BS_DEFPUSHBUTTON
      .F., ;                                    // <lPixel>   -
      .F., ;                                    // <lDesign>  -
      , ;                                       // <cMsg>     -
      .F., ;                                    // <lUpdate>  -
      , ;                                       // <bWhen>    -
      , ;                                       // <bValid>   -
      .F., ;                                    // <lCancel>  -
      , ;                                       // <cBitmap>  -
      , ;                                       // <cPosText> -
      OemToAnsi( "äöü ß ÄÖÜ éèêë ÉÈÊË" ), ;     // <cToolTip> -
      , ;                                       // <lFlat>    -
      , ;                                       // <cLayOut>  -
      ;                                         // <lGDIP>    -
      )                                         // CONSTRUCTOR

   ACTIVATE DIALOG oDlg

RETURN NIL
Regardss, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 392
Joined: Tue Mar 10, 2009 11:54 AM
Re: oBtn:ToolTip - UTF8 encoding fails [Unsolved]
Posted: Fri Nov 24, 2023 03:33 PM
thank you for the tip but I can't switch code pages for the following reason:

My application is a translation memory system (TMS) and should support as many languages as possible.
It should therefore be able to process, display and edit as many Unicode characters as possible at the same time, I think UTF8 is the best choice for this.

For example, there is a dialog to display all translations of a term, e.g. 'atmosphere':
Windows 11 Pro 22H2 22621.1848

Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384

Harbour 3.2.0dev (r2008190002)

FWH 23.10 x86
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: oBtn:ToolTip - UTF8 encoding fails [Unsolved]
Posted: Fri Nov 24, 2023 04:46 PM

We will look into the issue of tooltips.

Display of Utf8 depends purely on FWH

This has nothing to do with HB_CDPSELECT( "UTF8" ). This setting is useful only for Harbour file and directory functions when these names are in UTF8, applicable mostly for East Asian Language applications.

In my view, keep HB_CDPSELECT( <yourcontrycdp> )

Regards



G. N. Rao.

Hyderabad, India
Posts: 392
Joined: Tue Mar 10, 2009 11:54 AM
Re: oBtn:ToolTip - UTF8 encoding fails [Unsolved]
Posted: Sat Nov 25, 2023 12:14 PM
We will look into the issue of tooltips.
:D
Display of Utf8 depends purely on FWH
Does this mean that we can only use chars provided by FWH, even if we use a different font?

I tried it with the font 'unscii' from http://viznut.fi/unscii/, unfortunately without success!
This has nothing to do with HB_CDPSELECT( "UTF8" ). This setting is useful only for Harbour file and directory functions when these names are in UTF8, applicable mostly for East Asian Language applications.
Good to know.
...UTF8, applicable mostly for East Asian Language applications.
But there are many multibyte characters that occur in other non-East Asian languages and are not included in ANSI! E. g. Characters specific to Central and Eastern European languages (e.g., Czech, Polish, Hungarian) like Č, Ć, Đ, Ł, Ń, Ő, Ű, Ś, Š, Ž, etc., available in Latin Extended-A (ISO 8859-2).
In my view, keep HB_CDPSELECT( <yourcontrycdp> )
Yes, if you only want to process, display and edit the characters that use the same character set (code page). This is not the case in my environment!
Windows 11 Pro 22H2 22621.1848

Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384

Harbour 3.2.0dev (r2008190002)

FWH 23.10 x86
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: oBtn:ToolTip - UTF8 encoding fails [Unsolved]
Posted: Sat Nov 25, 2023 06:15 PM
UTF8 encoding fails - switches to Ansi - in BUTTON/TButton() and TBtnBmp() ToolTips!
Can you please make this modification in "window.prg" and try?

Locate these lines in the METHOD ShowToolTip() of Window.prg:
Code (fw): Select all Collapse
      if IsWindowUnicode( ::hWnd )
//         cText = HB_UTF8LEFT( cText, 98 )
         hWnd = CreateToolTipWNew( ::hWnd, cText, IfNil( ::lBalloon, lTTBalloon ), cTitle, hIcon, nClrFore, nClrBack, nWidth, nDelayTime, nDelayType )
      else
//         cText = Left( cText, 99 )
         hWnd = CreateToolTipANew( ::hWnd, cText, IfNil( ::lBalloon, lTTBalloon ), cTitle, hIcon, nClrFore, nClrBack, nWidth, nDelayTime, nDelayType )
      endif
Replace ALL these lines with this one line:
Code (fw): Select all Collapse
hWnd = CreateToolTipWNew( ::hWnd, cText, IfNil( ::lBalloon, lTTBalloon ), cTitle, hIcon, nClrFore, nClrBack, nWidth, nDelayTime, nDelayType )
Please try after this change.
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: oBtn:ToolTip - UTF8 encoding fails [Unsolved]
Posted: Sat Nov 25, 2023 06:47 PM
Does this mean that we can only use chars provided by FWH, even if we use a different font?
chars provided by FWH?

FWH does NOT provide any chars. FWH does not have any chars of its own.

FWH displays any text using Windows APIs

Any utf8 encoded text of any language in the World can be displayed using any Windows font.

Ansi encoded text containing some accented characters of WU languages can be displayed only with a font created using the corresponding Charset. But most FWH functions display them by converting them to utf8 encoding. (we will fix where there are some inadequacies still). Setting HB_CDPSELECT("UTF8") has nothing to do with this process.
Regards



G. N. Rao.

Hyderabad, India
Posts: 392
Joined: Tue Mar 10, 2009 11:54 AM
Re: oBtn:ToolTip - UTF8 encoding fails [Unsolved]
Posted: Sun Nov 26, 2023 08:53 AM
Any utf8 encoded text of any language in the World can be displayed using any Windows font.
This reassures me 8)
Please try after this change.
అది పోయింది, ధన్యవాదాలు.

Transliterates to "Adi poyindi, dhanyavādālu" in english :wink:

Windows 11 Pro 22H2 22621.1848

Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384

Harbour 3.2.0dev (r2008190002)

FWH 23.10 x86
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: oBtn:ToolTip - UTF8 encoding fails [Unsolved]
Posted: Sun Nov 26, 2023 09:08 AM

Thanks

Wondering how do you know my mother tongue?

India has 21 Unicode languages.

Regards



G. N. Rao.

Hyderabad, India
Posts: 392
Joined: Tue Mar 10, 2009 11:54 AM
Re: oBtn:ToolTip - UTF8 encoding fails [Unsolved]
Posted: Sun Nov 26, 2023 09:31 AM

Wow, I can't believe. We are downright ridiculous with our 4 multibytes.

Windows 11 Pro 22H2 22621.1848

Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384

Harbour 3.2.0dev (r2008190002)

FWH 23.10 x86
Posts: 392
Joined: Tue Mar 10, 2009 11:54 AM
Re: oBtn:ToolTip - UTF8 encoding fails [Unsolved]
Posted: Sun Nov 26, 2023 09:37 AM
Wondering how do you know my mother tongue?
I've asked ChatGPT :shock: :? 8)
The answer was:
... In Hyderabad, India, the main languages spoken are Telugu, Urdu and English. Telugu is the predominant language in Hyderabad and Telangana, while Urdu is used as the second official language...
Windows 11 Pro 22H2 22621.1848

Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384

Harbour 3.2.0dev (r2008190002)

FWH 23.10 x86
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: oBtn:ToolTip - UTF8 encoding fails [Unsolved]
Posted: Sun Nov 26, 2023 09:43 AM

WOW

Regards



G. N. Rao.

Hyderabad, India

Continue the discussion