FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveMac / FivePhone (iPhone, iPad) adding special characters in a get
Posts: 166
Joined: Wed Nov 25, 2015 07:13 PM
adding special characters in a get
Posted: Fri May 14, 2021 02:18 PM
Hello Antonio and Manuel,

I have a function to add a richtext, but in this function I can not type any special characters like ä, é

Is there a solution for it?

Here is my code:

Code (fw): Select all Collapse
FUNCTION RK_EditRichNotes(cTekst)

   LOCAL oDlg, cText := ''
   LOCAL oGet
   
   DEFINE DIALOG oDlg TITLE 'Aantekening' FROM 0, 0 TO 500, 600
      
   @ 35, 20 GET oGet VAR cText MEMO OF oDlg ;
      SIZE 560, 460
      
    oGet:SetRichText(.t.)
    oGet:SetImportGraf(.t.)
    oGet:AddHRuler()
    oGet:SetUndo(.t.)
    IF LEN(ALLTRIM(cTekst)) > 0
        cText := cTekst
        oGet:SetAttributedString(cText)
    ENDIF
    oGet:GoTop()
           
          
   @ 5, 500 BUTTON oBtnOk PROMPT 'Ok' OF oDlg ACTION cAanteken := oGet:GetRTF(), oDlg:END()
    oBtnOk:SetFont( 'Arial', 14 )
   
ACTIVATE DIALOG oDlg CENTERED

RETURN NIL
Kind regards,



René Koot
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: adding special characters in a get
Posted: Sun May 16, 2021 05:10 PM
Hello.
I see your code ....
cTekst is string from RTF content ?
oGet:SetAttributedString(cText) is only for set content from RTF ( copy RTF code in var and paste into text view ) .
the property method for text is oGet:setText( cTekst ) but it was not planned for text with special characters .
I create code for this .....

in mget.prg add this code ...
Code (fw): Select all Collapse
 METHOD SetUTF8Text( cText ) INLINE TxtSetUTF8Text( ::hWnd, cText )



in mgets.m add this code ....
Code (fw): Select all Collapse
HB_FUNC( TXTSETUTF8TEXT )
{
    TextView * memo = ( TextView * ) hb_parnl( 1 );
    NSString * string = [ [ [ NSString alloc ] initWithCString: HB_ISCHAR( 2 ) ? hb_parc( 2 ) : "" encoding:  NSUTF8StringEncoding ] autorelease ];
    
    [ memo setString : string ];
}




in your sample change :

//oGet:SetAttributedString(cTekst)
oGet:setutf8Text( cTekst )

for me this is ok.
regards
Posts: 166
Joined: Wed Nov 25, 2015 07:13 PM
Re: adding special characters in a get
Posted: Tue May 18, 2021 01:18 PM
Hello Manuel,

Thanks for your reply. Yes the cTekst is a string with RTF content.

Do I need to rebuild the libs after the suggested changes? Because now I get an error:
Code (fw): Select all Collapse
Message not found: TMULTIGET:SETUTF8TEXT
Kind regards,



René Koot
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: adding special characters in a get
Posted: Tue May 18, 2021 03:39 PM

René,

Yes, you have to rebuild FiveMac once you include the suggested changes in its source code

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 166
Joined: Wed Nov 25, 2015 07:13 PM
Re: adding special characters in a get
Posted: Sun May 23, 2021 03:16 PM
Hello Manuel and Antonio,

I have made the suggested changes to the files and rebuild the libs. However in the get I see all the special characters from the RichText. And I am still not able to put in characters like ä, é ....
Here is my code:
Code (fw): Select all Collapse
FUNCTION RK_EditRichNotes(cTekst)

   LOCAL oDlg, cText := ''
   LOCAL oGet
   
   DEFINE DIALOG oDlg TITLE 'Aantekening' FROM 0, 0 TO 500, 600
      
   @ 35, 20 GET oGet VAR cText MEMO OF oDlg ;
      SIZE 560, 460
      
    oGet:SetRichText(.t.)
    oGet:SetImportGraf(.t.)
    oGet:AddHRuler()
    oGet:SetUndo(.t.)
    IF LEN(ALLTRIM(cTekst)) > 0
        cText := cTekst
        oGet:setutf8Text( cText )
*       oGet:SetAttributedString(cText)
    ENDIF
    oGet:GoTop()
           
          
   @ 5, 500 BUTTON oBtnOk PROMPT 'Ok' OF oDlg ACTION cAanteken := oGet:GetRTF(), oDlg:END()
    oBtnOk:SetFont( 'Arial', 14 )
   
ACTIVATE DIALOG oDlg CENTERED

RETURN NIL


This only happens when I use the GET in combination with MEMO. I get to see this:
Code (fw): Select all Collapse
{\rtf1\ansi\ansicpg1200\deff0\nouicompat\deflang1043{\fonttbl{\f0\fnil\fcharset0 ArialMT;}{\f1\froman\fprq2\fcharset0 ArialMT;}}
{\colortbl ;\red0\green0\blue0;}
{\*\generator Riched20 10.0.10240}\viewkind4\uc1 
\pard\cf1\f0\fs24 De grootst sierwaarde van deze boom is de donkerbruine bast die afschilfert in grote losse \par
krullen, waardoor de oranje onderlaag tevoorschijn komt.\par
\cf0\f1 Deze kleine boom heeft een bruine afschilferende bast. Het is een langzame groeier en daarom ook geschikt voor de wat kleinere tuin. Het kleine blad verkleurt in de herfst schitterend oranjerood. De bloei wordt gevolgd door gevleugelde nootvruchten die in trosjes aan de boom hangen.\par
Mooi als solitair met een onderbeplanting van bijvoorbeeld zegge (Carex morrowii) of sneeuwster-aster (Aster divaricatus). De wortel concurrentie van de Acer griseum is vrij groot, om die reden willen andere planten onder deze boom niet altijd makkelijk groeien.\cf1\f0\par
}
Kind regards,



René Koot
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: adding special characters in a get
Posted: Mon May 24, 2021 04:42 PM

René,

Are you able to paste those characters in the memo ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 166
Joined: Wed Nov 25, 2015 07:13 PM
Re: adding special characters in a get
Posted: Wed May 26, 2021 03:09 PM
Hello Antonio,
I have made an example.

If I use the oGet:setutf8Text( cText ) all the richtext formatting is shown and I can't put in characters like ä,é...

If I use the oGet:SetAttributedString(cText) the richtext formatting is NOT shown (so this is correct) but I still can't put in characters like ä, é...

IF I define the GET without MEMO I can put in the special characters. But then I can not set lists or text centered.

Code (fw): Select all Collapse
#include "FiveMac.ch"

function Main()

   LOCAL oWnd, cText := ''
   LOCAL oGet
   LOCAL cTekst := '{\rtf1\ansi\ansicpg1200\deff0\nouicompat\deflang1043{\fonttbl{\f0\fnil\fcharset0 ArialMT;}{\f1\froman\fprq2\fcharset0 ArialMT;}}{\colortbl ;\red0\green0\blue0;}{\*\generator Riched20 10.0.10240}\viewkind4\uc1\pard\cf1\f0\fs24 This is a RichText\cf1\f0\par}'
   
   DEFINE WINDOW oWnd TITLE 'RichNotes' FROM 0, 0 TO 500, 600
      
   @ 35, 20 GET oGet VAR cText MEMO OF oWnd ;
      SIZE 560, 460
      
   oGet:SetRichText(.t.)
   oGet:SetImportGraf(.t.)
   oGet:AddHRuler()
   oGet:SetUndo(.t.)
   IF LEN(ALLTRIM(cTekst)) > 0
      cText := cTekst
     oGet:setutf8Text( cText )
*      oGet:SetAttributedString(cText)
   ENDIF
   oGet:GoTop()
           
          
   @ 5, 500 BUTTON oBtnOk PROMPT 'Ok' OF oWnd ACTION MsgInfo(oGet:GetRTF(), 'richtext'), MsgInfo(oGet:GetText(), 'normal text')
      oBtnOk:SetFont( 'Arial', 14 )
   
ACTIVATE WINDOW oWnd CENTERED

            
return nil
Kind regards,



René Koot

Continue the discussion