mendix / CommunityCommons

This module adds a number reusable Java methods to your project, which can be called from Microflows or custom Java actions.
Apache License 2.0
13 stars 57 forks source link

stringToFile and stringFromFile both use UTF-8 #75

Closed dan-covaliu closed 5 years ago

dan-covaliu commented 5 years ago

StringToFile and StringFromFile both use UTF-8, which is not working with PDF files. If instead it would use ISO-8859-1, it would work properly, I tried it. The weird thing is, the PDF file is generated without errors, but is blank. If, on the other hand, the intended purpose of those functions is to work only with text files, this should be specified in the documentation of those Java Actions; and add similar actions for binary files.

reinouts commented 5 years ago

I looked into this and noted the documentation in the 'StringFromFile' action:

Note that this might give strange results when using with binary files. In that case, use the Base64 functions.

So I'm going to assume this behavior is intentional. If you have trouble using the Base64 functions, please file a separate issue. Thanks!

dan-covaliu commented 5 years ago

The results of StringFromFile, when used with PDF files, are not merely "strange", it's just that UTF-8 is hard coded inside. PDF files are not Base64-encoded. Base64 is a weak encoding of text information. Maybe we need a version of those JA where you could specify the encoding. Or PDFTo/FromFile.

reinouts commented 5 years ago

Hi Dan,

If you'd like to create a PR where the two actions take an (optional) charset parameter I'd be willing to review and eventually merge it.

dan-covaliu commented 5 years ago

Thank you Reinout,

I did a PR. Fair warning though, I’m not a Java person, so feel free to review and rectify the changes as you see fit. Cheers!

Regards, | Cordialement,

Dan Covaliu Software Integrator and Designer | Intégrateur et concepteur de logiciel T 514-496-1479 F 514-496-9344

bdc.cahttp://www.bdc.ca/EN/Pages/home.aspx?utm_campaign=signature&utm_medium=email&utm_source=signature

From: Reinout van Schouwen notifications@github.com Sent: April 26, 2019 4:55 AM To: mendix/CommunityCommons CommunityCommons@noreply.github.com Cc: COVALIU, Dan (MTL) Dan.Covaliu@bdc.ca; Author author@noreply.github.com Subject: Re: [mendix/CommunityCommons] stringToFile and stringFromFile both use UTF-8 (#75)

Hi Dan,

If you'd like to create a PR where the two actions take an (optional) charset parameter I'd be willing to review and eventually merge it.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://can01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmendix%2FCommunityCommons%2Fissues%2F75%23issuecomment-486981789&data=02%7C01%7Cdan.covaliu%40bdc.ca%7C9b426bbcefb14d76777608d6ca24d64a%7Cd850fe642c1344d0a5b3fedbb4edffbd%7C0%7C0%7C636918656897054013&sdata=gJwJcSKtMr7vS3XWp8w%2FrYRGdaMVfARWCPOOGNJRrXM%3D&reserved=0, or mute the threadhttps://can01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAD2N3OSJCD7BVNEP6WOMRZTPSK7NNANCNFSM4HEU3AVA&data=02%7C01%7Cdan.covaliu%40bdc.ca%7C9b426bbcefb14d76777608d6ca24d64a%7Cd850fe642c1344d0a5b3fedbb4edffbd%7C0%7C0%7C636918656897064017&sdata=ixceCzp1eL4%2BImN32DQNYZ00H6glUkkuzQ2E78vssnI%3D&reserved=0.


Confidentiality Warning: This message and any attachments are intended only for the use of the intended recipient(s), are confidential, and may be privileged. If you are not the intended recipient, you are hereby notified that any review, retransmission, conversion to hard copy, copying, circulation or other use of this message and any attachments is strictly prohibited. If you are not the intended recipient, please notify the sender immediately by return email, and delete this message and any attachments from your system. Thank you!

Information confidentielle: Le présent message, ainsi que tout fichier qui y est joint, est (sont) envoyé(s) à l'intention exclusive de son ou (ses) destinataire(s); il est de nature confidentielle et peut faire l'objet d'une information privilégiée. Nous avisons toute personne autre que le destinataire prévu que tout examen, réacheminement, impression, copie, distribution ou toute autre utilisation de ce message et tout document joint est (sont) strictement interdit(s). Si vous n'êtes pas le destinataire prévu, veuillez en aviser immédiatement l'expéditeur par retour de courriel et supprimer ce message et tout document joint de votre système. Merci!