How can I distinguish ß (Sharp s) and ss with 'basic macro'

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
billylee
Posts: 4
Joined: Fri Jun 08, 2018 10:10 am

How can I distinguish ß (Sharp s) and ss with 'basic macro'

Post by billylee »

German letters were created while automatically converting pdf documents to docs.
Unfortunately, I was unable to distinguish between ß (Sharp s) and ss while doing other operations using macros.
I am looking for a way to avoid this. I have encountered 'basic macro' today.
I am doing the following work.


     oReplace.setSearchString ("ß") 'Please do not change "ss"
     oReplace.setReplaceString ("fl")
        
     oReplace.SearchRegularExpression = True 'Use regular expressions
     oReplace.searchAll = True 'Do the entire document
     oDoc.replaceAll (oReplace)
LibreOffice 4.2.8.2
User avatar
Sébastien C
Posts: 111
Joined: Mon Jan 04, 2010 5:06 pm
Location: Meymac, France

Re: How can I distinguish ß (Sharp s) and ss with 'basic mac

Post by Sébastien C »

Hello billylee and welcome on this forum,

I am not sure to understand your question. But it is true that if we search “ß” in a document LibreOffice found characters string “ss”

It is a same problem with single long s (old typography) that I know so well...

You have for that to specify to respect the case sensitive.

Code: Select all

oReplace.setSearchString ("ß") 'Please do not change "ss"
oReplace.setReplaceString ("fl")
oReplace.SearchCaseSensitive = True ' Set the case sensitive
oReplace.SearchRegularExpression = True ' Use regular expressions
oReplace.searchAll = True 'Do the entire document
oDoc.replaceAll (oReplace) 
Viele Gruße
:lol:
LibreOffice v. 7.3.2.2, under GNU-Linux Mint and, in virtualization and just for tests, LibreOffice v. 7.3.2.2 an OpenOffice v. 4.1.12 under M$-W 10 :ouch: .
billylee
Posts: 4
Joined: Fri Jun 08, 2018 10:10 am

Re: How can I distinguish ß (Sharp s) and ss with 'basic mac

Post by billylee »

Thank you for answer.
My question is that "ss" changes while changing "ß". I do not need the letter ß at all. In Asia, I do not use German a lot.
LibreOffice 4.2.8.2
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How can I distinguish ß (Sharp s) and ss with 'basic mac

Post by Villeroy »

Do it like the Swiss do. They abolished all uses of ß in favour of ss. Just perform a simple find/replace. No macro code required.
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
User avatar
Sébastien C
Posts: 111
Joined: Mon Jan 04, 2010 5:06 pm
Location: Meymac, France

Re: How can I distinguish ß (Sharp s) and ss with 'basic mac

Post by Sébastien C »

@billylee
If you are not in a macro context (I mean if your code is not include in a code that you use yet), Villeroy say right : just perform a simple find/replace. But if you are in a macro context, the code can be there:

Code: Select all

Sub byBySharpS
	Dim oReplace As Object

	oReplace = thisComponent.CreateReplaceDescriptor()
 
	oReplace.setSearchString  ("ß")          '
	oReplace.setReplaceString ("ss")
	oReplace.SearchCaseSensitive     = True ' Set the case sensitive
	oReplace.SearchRegularExpression = True ' Use regular expressions
	oReplace.searchAll               = True ' Do the entire document.

	thisComponent.replaceAll (oReplace) 
End Sub
@Villeroy
We do not know the context where billylee is! :roll: I can talk for my self about the long S witch it has been abolished in France since the end of the eighteenth century; and it is not for the sake of it that the question of transcribing it in a historical context cannot be posted in this forum!
There are even places where one gets here or there a specialty that LibreOffice solves!

Similarly, if billylee asks to make a change in macro, it is because he is probably in such a context!
LibreOffice v. 7.3.2.2, under GNU-Linux Mint and, in virtualization and just for tests, LibreOffice v. 7.3.2.2 an OpenOffice v. 4.1.12 under M$-W 10 :ouch: .
billylee
Posts: 4
Joined: Fri Jun 08, 2018 10:10 am

Re: How can I distinguish ß (Sharp s) and ss with 'basic mac

Post by billylee »

Thank you for your answers. My job is to edit many documents. So I need macro function.
If my document is not a binary document but text, I can simply do the following:
sed -i "s / ß / fl / d" * .doc

One hint is that the "match case" checkbox provided by Openoffice distinguishes between two characters.
LibreOffice 4.2.8.2
User avatar
Sébastien C
Posts: 111
Joined: Mon Jan 04, 2010 5:06 pm
Location: Meymac, France

Re: How can I distinguish ß (Sharp s) and ss with 'basic mac

Post by Sébastien C »

So, if I resume your desire (because I do not understand yet well), you searching a macro for:
make an inventory of the name’s files for a complete directory.
  • open each file.
  • search and replace the “ß” character by “fl”.
  • close each file.
If I am right, say OK. But if I am wrong, please, say the incremental parts of what you want.
LibreOffice v. 7.3.2.2, under GNU-Linux Mint and, in virtualization and just for tests, LibreOffice v. 7.3.2.2 an OpenOffice v. 4.1.12 under M$-W 10 :ouch: .
billylee
Posts: 4
Joined: Fri Jun 08, 2018 10:10 am

Re: How can I distinguish ß (Sharp s) and ss with 'basic mac

Post by billylee »

Hello. What I want is a script-level behavior that does not involve people needing to open, close, or click on a file. Let's say the document is 10,000. The most fundamental cause of this problem is that Openoffice can not distinguish between two letters. (Default mode). Maybe it does not seems to be resolved.
And as already mentioned
"My problem is that "ss" is also changed while changing "ß".
Lastly, the intention is not to solve this problem, but to let you know that this problem exists.

Thank you.
LibreOffice 4.2.8.2
User avatar
Sébastien C
Posts: 111
Joined: Mon Jan 04, 2010 5:06 pm
Location: Meymac, France

Re: How can I distinguish ß (Sharp s) and ss with 'basic mac

Post by Sébastien C »

billylee wrote:My problem is that "ss" is also changed while changing "ß".
I really do not understand.

If I check the "match case" in my LibreOffice, it is not happening like you describe; “ss” is preserved. Do you really work on LibreOffice 4.2.8.2 as you say in signature or OpenOffice?
LibreOffice v. 7.3.2.2, under GNU-Linux Mint and, in virtualization and just for tests, LibreOffice v. 7.3.2.2 an OpenOffice v. 4.1.12 under M$-W 10 :ouch: .
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How can I distinguish ß (Sharp s) and ss with 'basic mac

Post by Villeroy »

There is not a single developer on this forum. Bugs have to be reported to the bug tracker.
I don't understand the problem neither.
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