TGet():ReDefine - UTF8 encoding fails [Solved]

TGet():ReDefine - UTF8 encoding fails [Solved]

Postby frose » Sun Nov 12, 2023 10:00 am

Encoding fails - switches to Ansi - when editing and the PICTURE clause is involved!
Image

Code: Select all  Expand view
#include "fivewin.ch"

#define ID_GET       4001
#define ID_BUTTON    4002

REQUEST HB_CODEPAGE_UTF8

FUNCTION Main()

   LOCAL oDlg
   LOCAL oGet
   LOCAL cVar1 := "üäö"
   
   FW_SetUnicode( .T. )

   DEFINE DIALOG oDlg RESOURCE "RES_UTF8"
   
   REDEFINE GET oGet VAR cVar1 ID ID_GET PICTURE "@70" OF oDlg
   //REDEFINE GET oGet VAR cVar1 ID ID_GET PICTURE "@!70" OF oDlg

   REDEFINE BUTTON ID ID_BUTTON OF oDlg ACTION MsgInfo( "<cVar1>: " + Trim( cVar1 ) + CRLF + StrToHex( cVar1, " " ) )

   ACTIVATE DIALOG oDlg CENTERED
   
RETURN NIL
 
Resource file:
Code: Select all  Expand view
// RESOURCE SCRIPT generated by "Pelles C for Windows, version 12.00".

#include <windows.h>
#include <commctrl.h>
#include <richedit.h>
#include "..\..\..\Program Files\PellesC\Include\Win\windows.h"

LANGUAGE LANG_NEUTRAL,SUBLANG_NEUTRAL

RES_UTF8 DIALOGEX DISCARDABLE 6, 18, 210, 142
STYLE DS_SHELLFONT|WS_POPUP|DS_MODALFRAME|DS_CONTEXTHELP|DS_3DLOOK|WS_CAPTION|WS_SYSMENU|WS_VISIBLE
CAPTION "Dialog"
FONT 8, "Tahoma", 0, 0, 1
{
  CONTROL "OK", IDOK, "Button", WS_TABSTOP, 160, 5, 45, 15
  CONTROL "Cancel", IDCANCEL, "Button", WS_TABSTOP, 160, 23, 45, 15
  CONTROL "Edit üöä 早晨好", 4001, "Edit", ES_AUTOHSCROLL|WS_BORDER|WS_TABSTOP, 4, 12, 64, 12
  CONTROL "Show üöä مرحبا", 4002, "Button", WS_TABSTOP, 4, 44, 68, 14
}
 

Consequently, the same thing still happens in TGet(), see https://forums.fivetechsupport.com/viewtopic.php?f=3&t=43709&

Encoding is ok without PICTURE clause
Code: Select all  Expand view
REDEFINE GET oGet VAR cVar1 ID ID_GET  OF oDlg
or with VARCHAR clause
Code: Select all  Expand view
REDEFINE GET oGet VAR cVar1 ID ID_GET VARCHAR 70 OF oDlg
Last edited by frose on Sun Nov 12, 2023 4:07 pm, edited 1 time in total.
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

Re: TGet():ReDefine - UTF8 encoding fails [Unsolved]

Postby nageswaragunupudi » Sun Nov 12, 2023 11:46 am

PICTURE "@70"


What is this picture clause? What is its purpose and use?
Regards

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

Re: TGet():ReDefine - UTF8 encoding fails [Unsolved]

Postby frose » Sun Nov 12, 2023 1:12 pm

Ooops, at some point the 'S' got lost, should be '@S70'
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

Re: TGet():ReDefine - UTF8 encoding fails [Unsolved]

Postby nageswaragunupudi » Sun Nov 12, 2023 1:14 pm

should be '@S70'

Ok. I know @S70.

It is useful in DOS programs only.
What do you think is its use in a Windows Get?
Regards

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

Re: TGet():ReDefine - UTF8 encoding fails [Solved]

Postby frose » Sun Nov 12, 2023 1:39 pm

maybe it's useless :oops:
Ok I'll use VARCHAR instead of '@S' and WinUpper() instead of '@!'?
Code: Select all  Expand view
@  20, 20 GET oGet VAR cVar1 SIZE 200,20 PIXEL OF oDlg VARCHAR 70 ON CHANGE { || cVar1 := WinUpper( cVar1 ), oDlg:Update() }

and never use the PICTURE clause for strings again :D
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

Re: TGet():ReDefine - UTF8 encoding fails [Unsolved]

Postby nageswaragunupudi » Sun Nov 12, 2023 2:15 pm

Code: Select all  Expand view
@  20, 20 GET oGet VAR cVar1 PICTUE "@!" SIZE 200,20 PIXEL OF oDlg VARCHAR 70 ON CHANGE { || oDlg:Update() }
 


In Unicode Gets picture clause "@!" works.

Please do not use any other picture clauses.

We can also use the clauses
Code: Select all  Expand view
CASE "UPPER"
CASE "LOWER"
CASE "PROPER"


Code: Select all  Expand view
VARCHAR <nMaxChars>
// or
VARCHAR { <nMinChars>, <nMaxChars> )

Variable length Gets are implemented by FWH only. Such feature is not availabe in pure (x)Harbour. Only fixed length editing
Regards

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

Re: TGet():ReDefine - UTF8 encoding fails [Solved]

Postby frose » Sun Nov 12, 2023 2:44 pm

Ok, thanks for clarification.

In Unicode Gets picture clause "@!" works.

Confirm that the PICTURE clause "@!" works for TGet():Redefine and TGet():New and UTF8!
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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 55 guests