Results 1 to 5 of 5

Thread: Remove RTF char from text

  1. #1
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,881

    Remove RTF char from text

    Hi all,
    I need to import data written on RTF format:
    this is the VFP memo:
    {\rtf1\ansi\ansicpg1252\deff0\deflang1040{\fonttbl {\f0\fnil\fcharset0 ;}}\viewkind4\uc1\pard\f0\fs18 Fornire le molle sempre lucide e non opache, mettere sempre in forno da sole.\par }

    I need to import this memo into Lianja Varchar as a simple text.

    Is possible?

    thanks
    Fabio

  2. #2
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    1,942
    Python has libraries and code snippets that will decode rtf. And of course can run in Lianja.

    You will need to do some research to see what works for you.

    Google search "python decode rtf" without the quotes and you will see many options.

    Here's one that uses regex (the long post with the code -- note the comment to the post): https://stackoverflow.com/questions/...ng-any-library

    Using a library would likely prove more robust -- apparently there are lots of "gotchas" in converting RTF to UTF-8 (Lianja is UTF-8 by default).

    Happy hunting!

    Hank
    Last edited by HankFay; 2020-03-25 at 13:36.

  3. #3
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,881
    Thank Hank
    now I've foud this:

    loForm = CREATEOBJECT("RICHTEXT.RichTextCtrl.1")
    m_lsRTF = inventtable.itemnotes
    loForm.textRTF = m_lsRTF
    replace inventtable.itemnotes with loForm.text

    and work fine.
    Not too speed.. but work.

  4. #4
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    1,942
    Hi Phabio,

    Yes, that works. That won't work on Linux (or Mac). And whether it can work at scale would need to be tested.

    I'm glad it works for your situation. That said, learning to add Python libraries into your apps would have open a lot of doors.

    Hank

  5. #5
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,881
    Yes, you'r right.. but in this case it's only for a local data import..

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us