cancel
Showing results for 
Search instead for 
Did you mean: 

comment with utf-8 character encoding

saeidrastak
Champ in-the-making
Champ in-the-making
Hi all,

when i add a comment with utf-8 character encoding, every thing is fine but when i read that comment , the fullMessage property of comment has bad characters( e.g ???????????????????)

best regards.
2 REPLIES 2

ismaelgarcia
Champ in-the-making
Champ in-the-making
If anyonw is interested i had the same problem with taskcomments.

Activiti 5.16.3 with postgres.

The soluction i found was to modify CommentEntity.java in activiti-engine to handle UFT-8 encoding while saving and reading the comment from the blob column.

Extract from org/activiti/engine/impl/persistence/entity/CommentEntity
<java>
  public byte[] getFullMessageBytes() {
    try {
  return (fullMessage!=null ? fullMessage.getBytes("UTF-8") : null);
} catch (UnsupportedEncodingException e) {
  return (fullMessage!=null ? fullMessage.getBytes() : null);
}
  }

  public void setFullMessageBytes(byte[] fullMessageBytes) {
    try {
  fullMessage = (fullMessageBytes!=null ? new String(fullMessageBytes, "UTF-8") : null );
} catch (UnsupportedEncodingException e) {
  fullMessage = (fullMessageBytes!=null ? new String(fullMessageBytes) : null ); }
  }
</java>

With this modification I was able to save and read special characters (ñ,é,ò. etc..)

Maybe its a bug.



jbarrez
Star Contributor
Star Contributor
I indeed think that's a bug. Would you be willing to create a pull request for this?