oBtn:ToolTip - UTF8 encoding fails [Unsolved]

Post Reply
User avatar
frose
Posts: 392
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Rietberg
Contact:

oBtn:ToolTip - UTF8 encoding fails [Unsolved]

Post by frose »

UTF8 encoding fails - switches to Ansi - in BUTTON/TButton() and TBtnBmp() ToolTips!

Sample:

Code: Select all | Expand

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

 
Image

For TButtonBmp() encoding is ok:
Image
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
User avatar
karinha
Posts: 7885
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Contact:

Re: oBtn:ToolTip - UTF8 encoding fails [Unsolved]

Post by karinha »

E asi?

Code: Select all | Expand

// 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
User avatar
frose
Posts: 392
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Rietberg
Contact:

Re: oBtn:ToolTip - UTF8 encoding fails [Unsolved]

Post by frose »

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':
Image
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
User avatar
nageswaragunupudi
Posts: 10691
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: oBtn:ToolTip - UTF8 encoding fails [Unsolved]

Post by nageswaragunupudi »

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
User avatar
frose
Posts: 392
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Rietberg
Contact:

Re: oBtn:ToolTip - UTF8 encoding fails [Unsolved]

Post by frose »

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
User avatar
nageswaragunupudi
Posts: 10691
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: oBtn:ToolTip - UTF8 encoding fails [Unsolved]

Post by nageswaragunupudi »

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

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

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
User avatar
nageswaragunupudi
Posts: 10691
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: oBtn:ToolTip - UTF8 encoding fails [Unsolved]

Post by nageswaragunupudi »

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
User avatar
frose
Posts: 392
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Rietberg
Contact:

Re: oBtn:ToolTip - UTF8 encoding fails [Unsolved]

Post by frose »

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:

Image
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
User avatar
nageswaragunupudi
Posts: 10691
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: oBtn:ToolTip - UTF8 encoding fails [Unsolved]

Post by nageswaragunupudi »

Thanks
Wondering how do you know my mother tongue?
India has 21 Unicode languages.
Regards

G. N. Rao.
Hyderabad, India
User avatar
frose
Posts: 392
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Rietberg
Contact:

Re: oBtn:ToolTip - UTF8 encoding fails [Unsolved]

Post by frose »

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
User avatar
frose
Posts: 392
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Rietberg
Contact:

Re: oBtn:ToolTip - UTF8 encoding fails [Unsolved]

Post by frose »

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
User avatar
nageswaragunupudi
Posts: 10691
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: oBtn:ToolTip - UTF8 encoding fails [Unsolved]

Post by nageswaragunupudi »

WOW
Regards

G. N. Rao.
Hyderabad, India
Post Reply