[Solved] ReplaceDescriptor/UTF-8

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
BubikolRamios
Posts: 91
Joined: Sat Jan 04, 2014 1:28 pm

[Solved] ReplaceDescriptor/UTF-8

Post by BubikolRamios »

ü and such is a problem, does not get replaced in document. Any idea ?

Code: Select all

 matrix = Array(_
...
   Array ("überragend"," outstanding "),_

...

 oReplace = oDoc.createReplaceDescriptor()

  For i= Lbound(matrix,1) To Ubound(matrix,1)
  
    
     oReplace.SearchString = matrix(i)(0)           'Regular expression. Match any text
     oReplace.ReplaceString =  matrix(i)(1)           'Note the & places the found text back
     oReplace.SearchRegularExpression=False  'Use regular expressions
     oReplace.SearchCaseSensitive = False
     oReplace.searchAll=True                'Do the entire document
  
     oDoc.replaceAll(oReplace)
  Next i
Last edited by BubikolRamios on Sun Jun 14, 2020 2:34 pm, edited 1 time in total.
OPen office 4.1.5/ win 7
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: ReplaceDescriptor/UTF-8

Post by Villeroy »

Works for me
Attachments
outstanding.odt
(12.2 KiB) Downloaded 160 times
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
BubikolRamios
Posts: 91
Joined: Sat Jan 04, 2014 1:28 pm

Re: ReplaceDescriptor/UTF-8

Post by BubikolRamios »

Do explain following:
have two doc opened. In one there is iiberragend in bwetween of all other stuff, Copy all to second opened doc and ii becomes ü.

Doing replace on second doc.
Must be something with encoding .... ü that I see not realy beeing ü.
OPen office 4.1.5/ win 7
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: ReplaceDescriptor/UTF-8

Post by Villeroy »

Encoding in ODF documents is always UTF-8.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
BubikolRamios
Posts: 91
Joined: Sat Jan 04, 2014 1:28 pm

Re: ReplaceDescriptor/UTF-8

Post by BubikolRamios »

So, the doc 1 has really been MS doc, after saving it into odt, copy paste does not produce ü anymore , ii stays ii.
OPen office 4.1.5/ win 7
User avatar
RoryOF
Moderator
Posts: 34586
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: [Solved]ReplaceDescriptor/UTF-8

Post by RoryOF »

Copy and Paste your entire document into a blank .odt file; this should remove most, if not all, of MS .doc's voodoo.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Solved]ReplaceDescriptor/UTF-8

Post by Villeroy »

MS docs before Office 97 may have different encodings. When you have to open such things:
menu:File>Open...
Choose file type "MS Word 6.0 / 95 (*.doc)"
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply