PureBasic 73 and editor Gadget RTF File

Just starting out? Need help? Post your questions and find answers here.
loulou2522
Enthusiast
Enthusiast
Posts: 495
Joined: Tue Oct 14, 2014 12:09 pm

PureBasic 73 and editor Gadget RTF File

Post by loulou2522 »

The following Richedit text
{
\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1036{\fonttbl{\f0\fnil\fcharset0 Calibri;}{\f1\fnil\fcharset2 Symbol;}}{\colortbl ;\red0\green64\blue128;}{\*\generator Riched20 10.0.18362}\viewkind4\uc1\pard\sl240\slmult1\cf1\b\f0\fs22\lang12Samedi 22 janvier 2022 \b0\cf0 Cr\$0027e9ation effectu\$0027e9e dans le logiciel de suivi par Patrick \$0027e0 10:26:45\par
With PB 5.72 result
Samedi 22 janvier 2022 Création effectuée dans le logiciel de suivi par Patrick à 10:11:25
Wiht PB 5.73
Samedi 22 janvier 2022 Cr ation effectu e dans le logiciel de suivi par Patrick 10:11:25
Can someone help me to solve this problem ?
P.S The font use is Calibri 10pt
infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: PureBasic 73 and editor Gadget RTF File

Post by infratec »

Normaly: no working code ... no help.

But since I'm helpy ...

Unfortunatelky if I save your quoted RTF to a file test.rtf, it is not a valid rtf file.
So I can definately not help you.
User avatar
STARGÅTE
Addict
Addict
Posts: 2067
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: PureBasic 73 and editor Gadget RTF File

Post by STARGÅTE »

Your RTF-code results on my system:
PB 5.72 wrote:Samedi 22 janvier 2022 Cr$0027e9ation effectu$0027e9e dans le logiciel de suivi par Patrick $0027e0 10:26:45
PB 5.73 wrote:Samedi 22 janvier 2022 Cr$0027e9ation effectu$0027e9e dans le logiciel de suivi par Patrick $0027e0 10:26:45
PB 6.00 wrote:Samedi 22 janvier 2022 Cr$0027e9ation effectu$0027e9e dans le logiciel de suivi par Patrick $0027e0 10:26:45
WordPad wrote:Samedi 22 janvier 2022 Cr$0027e9ation effectu$0027e9e dans le logiciel de suivi par Patrick $0027e0 10:26:45
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: PureBasic 73 and editor Gadget RTF File

Post by infratec »

If I write the text in Wordpad it looks like:
{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1036{\fonttbl{\f0\fnil\fcharset0 Calibri;}}
{\colortbl ;\red0\green64\blue128;}
{\*\generator Riched20 10.0.19041}\viewkind4\uc1
\pard\sl240\slmult1\cf1\b\f0\fs22\lang12 Samedi 22 janvier 2022 \cf0\b0 Cr\'e9ation effectu\'e9e dans le logiciel de suivi par Patrick \'e0 10:26:45\par
}
infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: PureBasic 73 and editor Gadget RTF File

Post by infratec »

\'e9 is not correct interpreted.
Instead you can use \u233?
e9 hex is 233 dezimal.

Code: Select all

;RTF$ = "{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1036{\fonttbl{\f0\fnil\fcharset0 Calibri;}}{\colortbl ;\red0\green64\blue128;}{\*\generator Riched20 10.0.19041}\viewkind4\uc1 \pard\sl240\slmult1\cf1\b\f0\fs22\lang12 Samedi 22 janvier 2022 \cf0\b0 Cr\'e9ation effectu\'e9e dans le logiciel de suivi par Patrick \'e0 10:26:45\par}"
RTF$ = "{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1036{\fonttbl{\f0\fnil\fcharset0 Calibri;}}{\colortbl ;\red0\green64\blue128;}{\*\generator Riched20 10.0.19041}\viewkind4\uc1 \pard\sl240\slmult1\cf1\b\f0\fs22\lang12 Samedi 22 janvier 2022 \cf0\b0 Cr\u233?ation effectu\u233?e dans le logiciel de suivi par Patrick \u224? 10:26:45\par}"

LoadFont(0, "Calabri", 11)
OpenWindow(0, 0, 0, 322, 150, "EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
EditorGadget(0, 8, 8, 306, 133)
SetGadgetFont(0, FontID(0))
SetGadgetText(0, RTF$)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
I don't know if it is a bug or not.
loulou2522
Enthusiast
Enthusiast
Posts: 495
Joined: Tue Oct 14, 2014 12:09 pm

Re: PureBasic 73 and editor Gadget RTF File

Post by loulou2522 »

infratec wrote: Sat Jan 22, 2022 4:53 pm Normaly: no working code ... no help.

But since I'm helpy ...

Unfortunatelky if I save your quoted RTF to a file test.rtf, it is not a valid rtf file.
So I can definately not help you.
I use $0027 because I save this rtf text in a postgresql database and the character ' cause trouble in my database so i load the data
with the folowwing instruct
SetGadgetText(Editor_0,ReplaceString( GetDatabaseString(ouvertureDatabase::ouverture,29) ,Chr(36)+"0027",Chr(39)))
infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: PureBasic 73 and editor Gadget RTF File

Post by infratec »

Procedure to convert \'XX to \uDDD?

Code: Select all

Procedure.s ChangeRTFUnicode(RTF$)
  
  Protected.i Pos
  
  Pos = 1
  Repeat
    Pos = FindString(RTF$, "\'", Pos)
    If Pos
      RTF$ = Left(RTF$, Pos) + "u" + Str(Val("$" + Mid(RTF$, Pos + 2, 2))) + "?" + Mid(RTF$, Pos + 4)
    EndIf
  Until Pos = 0
  
  ProcedureReturn RTF$
  
EndProcedure

RTF$ = "{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1036{\fonttbl{\f0\fnil\fcharset0 Calibri;}}{\colortbl ;\red0\green64\blue128;}{\*\generator Riched20 10.0.19041}\viewkind4\uc1 \pard\sl240\slmult1\cf1\b\f0\fs22\lang12 Samedi 22 janvier 2022 \cf0\b0 Cr\'e9ation effectu\'e9e dans le logiciel de suivi par Patrick \'e0 10:26:45\par}"
;RTF$ = "{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1036{\fonttbl{\f0\fnil\fcharset0 Calibri;}}{\colortbl ;\red0\green64\blue128;}{\*\generator Riched20 10.0.19041}\viewkind4\uc1 \pard\sl240\slmult1\cf1\b\f0\fs22\lang12 Samedi 22 janvier 2022 \cf0\b0 Cr\u233?ation effectu\u233?e dans le logiciel de suivi par Patrick \u224? 10:26:45\par}"

RTF$ = ChangeRTFUnicode(RTF$)

OpenWindow(0, 0, 0, 322, 150, "EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
EditorGadget(0, 8, 8, 306, 133)
SetGadgetText(0, RTF$)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Post Reply