[Dropped] Basic - Change String variable encoding

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
DCTN54
Posts: 10
Joined: Wed May 10, 2023 9:27 am

[Dropped] Basic - Change String variable encoding

Post by DCTN54 »

Hi,
how can I simply convert a string to a distinct character encoding inside my basic macro, without writing it to a file ?
(My macro sends an email and this string is the subject of the email - it seems encoding is different between my system mail and LibreOffice and some characters are not displayed properly).
Thanks for your help
Last edited by MrProgrammer on Mon Aug 28, 2023 4:50 am, edited 1 time in total.
Reason: Dropped: No response to questions in May 2023
LibreOffice 5.4.7.2.M6 on Windows 10
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

Re: Basic - Change String variable encoding

Post by JeJe »

Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
DCTN54
Posts: 10
Joined: Wed May 10, 2023 9:27 am

Re: Basic - Change String variable encoding

Post by DCTN54 »

Thanks for your answer but it didn't change anything, as, i guess, problem is on mail software side.
convertToUrl keeps my characters as they should be, but then my mail subject comes with a "file:///" header...
LibreOffice 5.4.7.2.M6 on Windows 10
DCTN54
Posts: 10
Joined: Wed May 10, 2023 9:27 am

Re: Basic - Change String variable encoding

Post by DCTN54 »

Replace(convertToUrl(myString),"file:///","") does the job but it's a bit of cheating...
LibreOffice 5.4.7.2.M6 on Windows 10
User avatar
Lupp
Volunteer
Posts: 3542
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Basic - Change String variable encoding

Post by Lupp »

DCTN54 wrote: Wed May 10, 2023 4:31 pm ... convert a string to a distinct character encoding...
... this string is the subject of the email - it seems encoding is different between my system mail ...
... and LibreOffice ...
... some characters are not displayed properly ...
You seem to have already a kind of workaround meeting your needs.
But, always trying to learn a bit, I would ask:

WHAT distinct character encoding are you talking of?
WHAT system is "my system" here?
WHAT service did you use to create the mail? WHAT method was used to set the subject?
WHAT characters are displayed WHERE not properly.

Basically an example consisting of 4 lines might help:
The subject string I fed into the process
The method call by which I tried to set the subject
The subject as I expected it to be displayed to the addressee
The actual display he(f/m) got.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
Cazer
Posts: 53
Joined: Mon May 15, 2023 11:55 am

Re: Basic - Change String variable encoding

Post by Cazer »

Hi @DCTN54,
I see you've found a workaround, but @Lupp brings up some good points. Knowing the specific encoding you're targeting, the system you're working on, the mail service you're using and how the subject is being set would be helpful.
Also, it would be useful to know exactly which characters aren't displaying properly and where they aren't displaying correctly. Sometimes it's a case of special characters or non-ASCII characters that aren't being handled right.
And if you have examples of the original subject string, the method call used, and what the subject should look like vs. what it actually looks like, those could be really helpful for us to provide better guidance.
OpenOffice 4.1.14
OS
Post Reply