Page 1 of 1

Utf8 Encoding

Posted: Fri Dec 30, 2016 1:16 am
by linnsystems
Processmaker 3.1.3 on Apache 2.4.7 on PHP 5.6.29.

When displaying case notes in dynaforms (using grid as documented in wiki), apostrophes and some other characters do not display correctly (apostrophe becomes &#39! ). This same behavior is also present when viewing case notes in the mobile app. Case notes display correctly when viewing them in the case notes pop-up icon on the web version of the case list. Also viewing the raw case notes in the database, they have correct characters.

MariaDB has correct settings and query reflects same:
Code: Select all
[client]
loose-default-character-set = utf8

[mysql]
loose-default-character-set = utf8

[mysqld]
collation-server = utf8_unicode_ci
loose-default-character-set = utf8
character-set-server = utf8
init-connect = 'SET NAMES utf8'
Apache is set to utf8 in char.conf and in pmos.conf and php.ini is also set to utf8 verified in the admin menu -> php information.

Please help me from pulling anymore of my hair out, am I missing (or misunderstanding) something?

Thanks.
Josh

Re: Utf8 Encoding

Posted: Thu Jan 05, 2017 12:07 am
by amosbatto
You can convert HTML entities (like &#39!) to their characters like this in a trigger:
Code: Select all
@@myString = html_entity_decode(@@myString);
linnsystems wrote: When displaying case notes in dynaforms (using grid as documented in wiki), apostrophes and some other characters do not display correctly (apostrophe becomes &#39! ).
Where do you see code example in the wiki? I want to change it.

Re: Utf8 Encoding

Posted: Thu Oct 11, 2018 3:33 pm
by richvle
Hi, following the instructions per https://wiki.processmaker.com/3.2/Proce ... otes.28.29
It looks like the display is showing special characters such as apostrophes as " ' ". Anybody have any idea how to resolve this?

I've tried using html_entity_decode during the insertion in a trigger, but that didn't seem to do it.
Code: Select all
@@NewCaseNote = "what's up";
@@ReturnValue_CaseNote = PMFAddCaseNote(@@APPLICATION, @@PROCESS, @@TASK, @@USER_LOGGED, html_entity_decode(@@NewCaseNote), 0);

Re: Utf8 Encoding

Posted: Mon Nov 12, 2018 5:58 pm
by richvle
Also, I think linnsystems (Josh) is referring to this trigger code:
@@gridPMFunction = PMFGetCaseNotes(@@APPLICATION, 'array', '');

per the documentation. I also have this problem. Josh, did you ever get it to work?

Re: Utf8 Encoding

Posted: Fri Nov 16, 2018 1:52 pm
by richvle
Ah OK, so if you followed up the instructions on the WIKI, you can either do

@@textAreaPMFunction = PMFGetCaseNotes(@@APPLICATION, 'string', '');
or
@@gridPMFunction = PMFGetCaseNotes(@@APPLICATION, 'array', '');

The HTML character problem can be fixed by doing add this line next...
@@textAreaPMFunction = PMFGetCaseNotes(@@APPLICATION, 'string', '');
@@textAreaPMFunction = htmlspecialchars_decode(@@textAreaPMFunction,ENT_QUOTES);

However, this only works when you are using it with the string parameter. For the one the uses an array, htmlspecialchars_decode won't work because it returns a string and we're dealing with an array. I'm going to see if I can get it to work by putting the array through a loop and working on it from there.

Re: Utf8 Encoding

Posted: Fri Nov 16, 2018 5:03 pm
by amosbatto
Did you figure it out?

Re: Utf8 Encoding

Posted: Fri Nov 16, 2018 5:10 pm
by amosbatto
The code would be something like this:
Code: Select all
@=notes = PMFGetCaseNotes(@@APPLICATION, 'array', '');

for ($i = 0; $i < count(@=notes); $i++) {
     @=notes[$i]['NOTE_CONTENT'] = htmlspecialchars_decode(@=notes[$i]['NOTE_CONTENT'], ENT_QUOTES);
} 

Re: Utf8 Encoding

Posted: Fri Nov 16, 2018 6:21 pm
by richvle
Thanks for replying Amos.
I couldn't get it work using other approaches. I tried using yours, (changed out your @=notes variable with @gridPMFunction to match the WIKI), but it still wasn't working.
Code: Select all
@=gridPMFunction = PMFGetCaseNotes(@@APPLICATION, 'array', '');

for ($i = 0; $i < count(@=gridPMFunction); $i++) {
     @=gridPMFunction[$i]['NOTE_CONTENT'] = htmlspecialchars_decode(@=gridPMFunction[$i]['NOTE_CONTENT'], ENT_QUOTES);
} 
Capture2.JPG
Capture2.JPG (30.2 KiB) Viewed 1375 times
amosbatto wrote: Fri Nov 16, 2018 5:10 pm The code would be something like this:
Code: Select all
@=notes = PMFGetCaseNotes(@@APPLICATION, 'array', '');

for ($i = 0; $i < count(@=notes); $i++) {
     @=notes[$i]['NOTE_CONTENT'] = htmlspecialchars_decode(@=notes[$i]['NOTE_CONTENT'], ENT_QUOTES);
} 

Re: Utf8 Encoding

Posted: Mon Nov 19, 2018 9:35 pm
by amosbatto
I just tried it in PM 3.2.3. You can use this code to convert from the html entities to normal text:
Code: Select all
@=notes = PMFGetCaseNotes(@@APPLICATION, 'array', '');

for ($i = 1; $i <= count(@=notes); $i++) {
   @=notes[$i]['NOTE_CONTENT'] = html_entity_decode(@=notes[$i]['NOTE_CONTENT'], ENT_QUOTES, 'UTF-8');
} 

Re: Utf8 Encoding

Posted: Tue Nov 20, 2018 5:54 am
by richvle
That did it! Thanks so much Amos.

incase anybody is doing it following the WIKI, here's the Amos's code with the modification using the WIKI Variable
Code: Select all
@@gridPMFunction = PMFGetCaseNotes(@@APPLICATION, 'array', '');

for ($i = 1; $i <= count(@=gridPMFunction); $i++) {
   @=gridPMFunction[$i]['NOTE_CONTENT'] = html_entity_decode(@=gridPMFunction[$i]['NOTE_CONTENT'], ENT_QUOTES, 'UTF-8');
}