web stats
Repair special characters - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 09-13-2018, 05:27 AM
mdehoog mdehoog is online now
Mirth Guru
 
Join Date: Mar 2011
Location: Apeldoorn the Netherlands
Posts: 245
mdehoog is on a distinguished road
Send a message via Skype™ to mdehoog
Default Repair special characters

Mirth Connct 3.6.1 is receiving HL7 messages from a legacy system and these messages contain wrongly encoded characters like:
Br├Ânnigan which should be Br÷nnigan.

Is there a way to repair these wrong encoded characters?
__________________
X Connections
http://www.x-connections.com
Reply With Quote
  #2  
Old 09-13-2018, 05:55 AM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 435
agermano is on a distinguished road
Default

Is your source connector set to the correct character encoding?
Reply With Quote
  #3  
Old 09-13-2018, 06:00 AM
mdehoog mdehoog is online now
Mirth Guru
 
Join Date: Mar 2011
Location: Apeldoorn the Netherlands
Posts: 245
mdehoog is on a distinguished road
Send a message via Skype™ to mdehoog
Default

I think so. I did try a few different ones, but I think because the messages is a string, these wrong characters are just a string for MC. If I send this:

PID|1||181685||Ik÷ens Br├Ân^^S.||

It will not 'repair' the ├ into a ÷ because it is seen as a string. The first ÷ is handle ok.
__________________
X Connections
http://www.x-connections.com
Reply With Quote
  #4  
Old 09-13-2018, 06:01 AM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 435
agermano is on a distinguished road
Default

Looks like maybe you are on windows and have the encoding set to default, but the legacy system is sending UTF-8. This produces the expected output.

Code:
var fixed = new java.lang.String(new java.lang.String('Br├Ânnigan').getBytes('windows-1252'),'UTF-8');
Reply With Quote
  #5  
Old 09-13-2018, 06:51 AM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 435
agermano is on a distinguished road
Default

I didn't see your second post before I posted the last time. The code I gave you won't work for 'Ik÷ens Br├Ân'. It will mess up the ÷ that did work correctly.

If the legacy system is mixing encodings, maybe you'll just have to do a replace for common character sequences.

Perhaps in the pre-processor you could do something like:

Code:
message = message.replace(/├Â/g,'÷');
Reply With Quote
  #6  
Old 09-19-2018, 02:57 AM
mdehoog mdehoog is online now
Mirth Guru
 
Join Date: Mar 2011
Location: Apeldoorn the Netherlands
Posts: 245
mdehoog is on a distinguished road
Send a message via Skype™ to mdehoog
Default

Think this is the only way to solve this.
Else it is sh*t in. sh*t out.
__________________
X Connections
http://www.x-connections.com
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 12:13 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Mirth Corporation