Page 1 of 1

HMG controls and ANSI / UTF8 strings

Posted: Fri Oct 14, 2016 12:49 pm
by esgici
Hi

Code: Select all

frmRectText.ebxText.Value := cInpText      
MsgDebug(  HMG_IsUTF8( cInpText ), HMG_IsUTF8(frmRectText.ebxText.Value ) ) // .F., .T:
It seems HMG controls automatically convert strings ANSI to Unicode :?

If so, this behavior seem is not convenient to me :(

Code: Select all

     IF !HMG_IsUTF8( cInpText ) 
        cInpText :=  HMG_ANSI_TO_UNICODE( cInpText )
     ENDIF
I don't like do frequently this (and converse) in prgs.

My string are not always uniform in format, sometime ANSI, sometime Unicode.

So SETtingCODEPAGE TO <one or auther> is not convenient for me. Because of this, working with IDE ANSI too don't solves my problem :(

Does may be a possibility that HMG controls treats strings as-is basis; if ANSI, ANSI, if Unicode, Unicode :?: :? (like modern text editors)

TIA

Re: HMG controls and ANSI / UTF8 strings

Posted: Fri Oct 14, 2016 3:45 pm
by srvet_claudio
See in source/debugger/dbgGUI.prg the function Load PRG.

Re: HMG controls and ANSI / UTF8 strings

Posted: Fri Oct 14, 2016 4:04 pm
by esgici
srvet_claudio wrote:See in source/debugger/dbgGUI.prg the function Load PRG.
If you are about this (line 1335-1339)

Code: Select all

      IF HMG_IsCurrentCodePageUnicode() == .T. .AND. HMG_IsUTF8( aLineCode [i] ) == .F.
         aLineCode [i] := HMG_ANSI_TO_UNICODE( aLineCode [i], NIL )
      ELSEIF HMG_IsCurrentCodePageUnicode() == .F. .AND. HMG_IsUTF8( aLineCode [i] ) == .T.
         aLineCode [i] := hb_UTF8ToStr( aLineCode [i], NIL )
      ENDIF
I couldn't explain my problem right; I don't want to repeat this code snap in every string operation.

I hope HMG controls can do this (again, like modern text editors).

Anyway thank to interest.

Viva HMG :D

Re: HMG controls and ANSI / UTF8 strings

Posted: Fri Oct 14, 2016 5:59 pm
by srvet_claudio
Introduce an internal function in each control that automatically convert an ANSI string to Unicode is possible but this change the standard behavior of Windows APIs.

Re: HMG controls and ANSI / UTF8 strings

Posted: Fri Oct 14, 2016 6:45 pm
by esgici
srvet_claudio wrote:Introduce an internal function in each control that automatically convert an ANSI string to Unicode is possible but this change the standard behavior of Windows APIs.
OK Dr., thanks :arrow:

Viva HMG :D

Re: HMG controls and ANSI / UTF8 strings

Posted: Sat Oct 15, 2016 5:34 pm
by esgici
esgici wrote:...
It seems HMG controls automatically convert strings ANSI to Unicode :? ...
Sorry, this sentence isn't correct :oops:

It should be :
It seems HMG controls automatically pretends ANSI strings as Unicode :?
Of course this occurs when compiling Unicode; ANSI compiling (fe via IDE_ANSI) Unicode strings treads as ANSI :(

If so, this behavior is worse to me :(

I don't want a compiler (or library) don't change my string's format.

Probably this isn't so facile, and is simply my personal approach.

FYI only.

TIA