Page 1 of 1

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

Posted: Fri Jun 08, 2018 10:24 am
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)

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

Posted: Sat Jun 09, 2018 12:34 pm
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:

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

Posted: Sat Jun 09, 2018 1:26 pm
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.

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

Posted: Sat Jun 09, 2018 1:35 pm
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.

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

Posted: Sat Jun 09, 2018 2:36 pm
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!

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

Posted: Sun Jun 10, 2018 9:20 am
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.

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

Posted: Sun Jun 10, 2018 12:41 pm
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.

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

Posted: Sun Jun 10, 2018 4:11 pm
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.

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

Posted: Sun Jun 10, 2018 4:53 pm
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?

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

Posted: Sun Jun 10, 2018 10:30 pm
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.