[Solved] ReplaceDescriptor/UTF-8

Creating a macro - Writing a Script - Using the API

[Solved] ReplaceDescriptor/UTF-8

Postby BubikolRamios » Sun Jun 14, 2020 9:01 am

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

Code: Select all   Expand viewCollapse view
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
BubikolRamios
 
Posts: 48
Joined: Sat Jan 04, 2014 1:28 pm

Re: ReplaceDescriptor/UTF-8

Postby Villeroy » Sun Jun 14, 2020 10:00 am

Works for me
Attachments
outstanding.odt
(12.2 KiB) Downloaded 17 times
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.4
User avatar
Villeroy
Volunteer
 
Posts: 28431
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: ReplaceDescriptor/UTF-8

Postby BubikolRamios » Sun Jun 14, 2020 2:24 pm

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
BubikolRamios
 
Posts: 48
Joined: Sat Jan 04, 2014 1:28 pm

Re: ReplaceDescriptor/UTF-8

Postby Villeroy » Sun Jun 14, 2020 2:28 pm

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, no OpenOffice, LibreOffice 6.4
User avatar
Villeroy
Volunteer
 
Posts: 28431
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: ReplaceDescriptor/UTF-8

Postby BubikolRamios » Sun Jun 14, 2020 2:32 pm

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
BubikolRamios
 
Posts: 48
Joined: Sat Jan 04, 2014 1:28 pm

Re: [Solved]ReplaceDescriptor/UTF-8

Postby RoryOF » Sun Jun 14, 2020 2:37 pm

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.7 on Xubuntu 18.04.4 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 31230
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: [Solved]ReplaceDescriptor/UTF-8

Postby Villeroy » Sun Jun 14, 2020 2:44 pm

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, no OpenOffice, LibreOffice 6.4
User avatar
Villeroy
Volunteer
 
Posts: 28431
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 3 guests